Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:27

0001 ///////////////////////////////////////////////////////////////////////////////
0002 /// \file template_arity.hpp
0003 /// Replace all nodes stored by reference by nodes stored by value.
0004 //
0005 //  Copyright 2011 Eric Niebler. Distributed under the Boost
0006 //  Software License, Version 1.0. (See accompanying file
0007 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 //  This file is based on a similar one in MPL from Aleksey Gurtovoy.
0010 
0011 #ifndef BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07
0012 #define BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07
0013 
0014 // Somewhat indirect definition of BOOST_PROTO_TEMPLATE_ARITY_PARAM is
0015 // to overcome a shortcoming of the Wave tool used to generate the
0016 // pre-preprocessed headers.
0017 #define BOOST_PROTO_TEMPLATE_ARITY_PARAM BOOST_PROTO_TEMPLATE_ARITY_PARAM2
0018 #define BOOST_PROTO_TEMPLATE_ARITY_PARAM2(param)
0019 
0020 #if defined(BOOST_PROTO_EXTENDED_TEMPLATE_PARAMETERS_MATCHING) ||                                   \
0021   (defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES))
0022 
0023 #include <boost/preprocessor/cat.hpp>
0024 #include <boost/preprocessor/inc.hpp>
0025 #include <boost/preprocessor/iteration/iterate.hpp>
0026 #include <boost/preprocessor/repetition/enum_params.hpp>
0027 #include <boost/mpl/int.hpp>
0028 #include <boost/proto/proto_fwd.hpp>
0029 
0030 #undef BOOST_PROTO_TEMPLATE_ARITY_PARAM2
0031 #define BOOST_PROTO_TEMPLATE_ARITY_PARAM2(param) , param
0032 
0033 namespace boost { namespace proto { namespace detail
0034 {
0035     sized_type<1>::type template_arity_helper(...);
0036 
0037     // Other overloads generated by the preprocessor
0038     #include <boost/proto/detail/template_arity_helper.hpp>
0039 
0040     template<typename F, int N, int Size>
0041     struct template_arity_impl2
0042       : mpl::int_<Size - 1>
0043     {};
0044 
0045     template<typename F, int N = BOOST_PROTO_MAX_ARITY>
0046     struct template_arity
0047       : template_arity_impl2<
0048             F
0049           , N
0050           , sizeof(detail::template_arity_helper((F **)0, (mpl::int_<N> *)0))
0051         >
0052     {};
0053 
0054     template<typename F, int N>
0055     struct template_arity_impl2<F, N, 1>
0056       : template_arity<F, N-1>
0057     {};
0058 
0059     template<typename F>
0060     struct template_arity_impl2<F, 0, 1>
0061       : mpl::int_<-1>
0062     {};
0063 
0064 }}}
0065 
0066 #endif // BOOST_PROTO_EXTENDED_TEMPLATE_PARAMETERS_MATCHING
0067 #endif // BOOST_PROTO_DETAIL_TEMPLATE_ARITY_HPP_EAN_2011_05_07