1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2008-2009: Joachim Faulhaber
3 +------------------------------------------------------------------------------+
4 Copyright (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
13 namespace boost{ namespace icl
16 template <typename Type>
17 Type abs(Type val) { return val < 0 ? -val : val; }
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.
25 @author Joachim Faulhaber
30 /** The size of a value is used to be able to order values according to
32 static std::size_t apply(const Type& val);
36 template<> inline std::size_t value_size<int>::apply(const int& value)
37 { return abs(value); }
39 template<> inline std::size_t value_size<double>::apply(const double& value)
40 { return static_cast<int>(abs(value)); }
42 template <typename Type>
43 inline std::size_t value_size<Type>::apply(const Type& value)
44 { return icl::iterative_size(value); }
48 }} // namespace boost icl