]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/icl/include/boost/icl/type_traits/value_size.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / icl / include / boost / icl / type_traits / value_size.hpp
CommitLineData
7c673cae
FG
1/*-----------------------------------------------------------------------------+
2Copyright (c) 2008-2009: Joachim Faulhaber
3+------------------------------------------------------------------------------+
4Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
5+------------------------------------------------------------------------------+
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENCE.txt or copy at
8 http://www.boost.org/LICENSE_1_0.txt)
9+-----------------------------------------------------------------------------*/
10#ifndef BOOST_ICL_VALUE_SIZE_HPP_JOFA_081004
11#define BOOST_ICL_VALUE_SIZE_HPP_JOFA_081004
12
13namespace boost{ namespace icl
14{
15
16template <typename Type>
17Type abs(Type val) { return val < 0 ? -val : val; }
18
19/// static class template for the size of a type's value
20/** This function is needed to be able to order values according
21 to their size. This is used to e.g. prefer simple test
22 instances and to express this simplicity independent of the
23 type of the test case.
24
25 @author Joachim Faulhaber
26*/
27template <class Type>
28struct value_size
29{
30 /** The size of a value is used to be able to order values according to
31 their simplicity */
32 static std::size_t apply(const Type& val);
33};
34
35
36template<> inline std::size_t value_size<int>::apply(const int& value)
37{ return abs(value); }
38
39template<> inline std::size_t value_size<double>::apply(const double& value)
40{ return static_cast<int>(abs(value)); }
41
42template <typename Type>
43inline std::size_t value_size<Type>::apply(const Type& value)
44{ return icl::iterative_size(value); }
45
46
47
48}} // namespace boost icl
49
50#endif
51
52