Chris@16: //////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // Copyright Vicente J. Botet Escriba 2010 Chris@16: // Chris@101: // Distributed under the Boost Software License, Version 1.0. Chris@101: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/mpl for documentation. Chris@16: // Chris@16: //////////////////////////////////////////////////////////////////// Chris@16: #ifndef BOOST_MPL_ABS_HPP_INCLUDED Chris@16: #define BOOST_MPL_ABS_HPP_INCLUDED Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #if !defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) \ Chris@16: && !defined(BOOST_MPL_PREPROCESSING_MODE) \ Chris@101: && !defined(__CUDACC__) \ Chris@16: && ( defined(BOOST_MSVC) \ Chris@16: || BOOST_WORKAROUND(__EDG_VERSION__, <= 238) \ Chris@16: ) Chris@16: Chris@16: # define BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2 Chris@16: Chris@16: #endif Chris@16: Chris@16: namespace boost { namespace mpl { Chris@16: Chris@16: template< typename Tag > struct abs_impl; Chris@16: Chris@16: template< typename T > struct abs_tag Chris@16: { Chris@16: typedef typename T::tag type; Chris@16: }; Chris@16: Chris@16: template< Chris@16: typename BOOST_MPL_AUX_NA_PARAM(N) Chris@16: > Chris@16: struct abs Chris@16: : abs_impl< Chris@16: typename abs_tag::type Chris@16: >::template apply::type Chris@16: { Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT(1, abs, (N)) Chris@16: }; Chris@16: Chris@16: BOOST_MPL_AUX_NA_SPEC(1, abs) Chris@16: Chris@16: template< Chris@16: typename T Chris@16: , T n1 Chris@16: > Chris@16: struct abs_c Chris@16: : abs > Chris@16: { Chris@16: }; Chris@16: Chris@16: #if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) Chris@16: namespace aux { Chris@16: template< typename T, T n > struct abs_wknd Chris@16: { Chris@16: BOOST_STATIC_CONSTANT(T, value = (n < 0 ? -n : n)); Chris@16: typedef integral_c type; Chris@16: }; Chris@16: } Chris@16: #endif Chris@16: Chris@16: template<> Chris@16: struct abs_impl Chris@16: { Chris@16: #if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2) Chris@16: template< typename N > struct apply Chris@16: : aux::abs_wknd< typename N::value_type, N::value > Chris@16: #else Chris@16: template< typename N > struct apply Chris@16: : integral_c< typename N::value_type, ((N::value < 0) ? (-N::value) : N::value ) > Chris@101: #endif Chris@16: { Chris@16: }; Chris@16: }; Chris@16: Chris@16: }} Chris@16: Chris@16: #endif // BOOST_MPL_ABS_HPP_INCLUDED