]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/icl/type_traits/value_size.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / 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
92f5a8d4 14{
7c673cae
FG
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
92f5a8d4 36template<> inline std::size_t value_size<int>::apply(const int& value)
7c673cae
FG
37{ return abs(value); }
38
92f5a8d4 39template<> inline std::size_t value_size<double>::apply(const double& value)
7c673cae
FG
40{ return static_cast<int>(abs(value)); }
41
92f5a8d4 42template <typename Type>
7c673cae
FG
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