1 ////////////////////////////////////////////////////////////////////
3 // Copyright Vicente J. Botet Escriba 2010
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // See http://www.boost.org/libs/mpl for documentation.
11 ////////////////////////////////////////////////////////////////////
12 #ifndef BOOST_MPL_ABS_HPP_INCLUDED
13 #define BOOST_MPL_ABS_HPP_INCLUDED
15 #include <boost/mpl/integral_c.hpp>
16 #include <boost/mpl/aux_/na_spec.hpp>
17 #include <boost/mpl/aux_/lambda_support.hpp>
18 #include <boost/mpl/aux_/config/integral.hpp>
19 #include <boost/mpl/aux_/config/static_constant.hpp>
21 #if !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) \
22 && !defined(BOOST_MPL_PREPROCESSING_MODE) \
23 && !defined(__CUDACC__) \
24 && ( defined(BOOST_MSVC) \
25 || BOOST_WORKAROUND(__EDG_VERSION__, <= 238) \
28 # define BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2
32 namespace boost { namespace mpl {
34 template< typename Tag > struct abs_impl;
36 template< typename T > struct abs_tag
38 typedef typename T::tag type;
42 typename BOOST_MPL_AUX_NA_PARAM(N)
46 typename abs_tag<N>::type
47 >::template apply<N>::type
49 BOOST_MPL_AUX_LAMBDA_SUPPORT(1, abs, (N))
52 BOOST_MPL_AUX_NA_SPEC(1, abs)
59 : abs<integral_c<T,n1> >
63 #if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2)
65 template< typename T, T n > struct abs_wknd
67 BOOST_STATIC_CONSTANT(T, value = (n < 0 ? -n : n));
68 typedef integral_c<T,value> type;
74 struct abs_impl<integral_c_tag>
76 #if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2)
77 template< typename N > struct apply
78 : aux::abs_wknd< typename N::value_type, N::value >
80 template< typename N > struct apply
81 : integral_c< typename N::value_type, ((N::value < 0) ? (-N::value) : N::value ) >
89 #endif // BOOST_MPL_ABS_HPP_INCLUDED