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_SIGN_HPP_INCLUDED
13 #define BOOST_MPL_SIGN_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 sign_impl;
36 template< typename T > struct sign_tag
38 typedef typename T::tag type;
42 typename BOOST_MPL_AUX_NA_PARAM(N)
46 typename sign_tag<N>::type
47 >::template apply<N>::type
49 BOOST_MPL_AUX_LAMBDA_SUPPORT(1, sign, (N))
52 BOOST_MPL_AUX_NA_SPEC(1, sign)
59 : sign<integral_c<T,n1> >
63 #if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2)
65 template< typename T, T n > struct sign_wknd
67 BOOST_STATIC_CONSTANT(T, value = (n == 0 ? 0 : (n < 0 ? -1 : 1)));
68 typedef integral_c<T,value> type;
74 struct sign_impl<integral_c_tag>
76 #if defined(BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC_2)
77 template< typename N > struct apply
78 : aux::sign_wknd< typename N::value_type, N::value >
80 template< typename N > struct apply
81 : integral_c< typename N::value_type, (N::value == 0 ? 0 : (N::value < 0 ? -1 : 1)) >
89 #endif // BOOST_MPL_SIGN_HPP_INCLUDED