1 // boost utility/base_from_member.hpp header file --------------------------//
\r
3 // Copyright 2001, 2003, 2004 Daryle Walker. Use, modification, and
\r
4 // distribution are subject to the Boost Software License, Version 1.0. (See
\r
5 // accompanying file LICENSE_1_0.txt or a copy at
\r
6 // <http://www.boost.org/LICENSE_1_0.txt>.)
\r
8 // See <http://www.boost.org/libs/utility/> for the library's home page.
\r
10 #ifndef BOOST_UTILITY_BASE_FROM_MEMBER_HPP
\r
11 #define BOOST_UTILITY_BASE_FROM_MEMBER_HPP
\r
13 #include <boost/preprocessor/arithmetic/inc.hpp>
\r
14 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
\r
15 #include <boost/preprocessor/repetition/enum_params.hpp>
\r
16 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
\r
19 // Base-from-member arity configuration macro ------------------------------//
\r
21 // The following macro determines how many arguments will be in the largest
\r
22 // constructor template of base_from_member. Constructor templates will be
\r
23 // generated from one argument to this maximum. Code from other files can read
\r
24 // this number if they need to always match the exact maximum base_from_member
\r
25 // uses. The maximum constructor length can be changed by overriding the
\r
26 // #defined constant. Make sure to apply the override, if any, for all source
\r
27 // files during project compiling for consistency.
\r
29 // Contributed by Jonathan Turkanis
\r
31 #ifndef BOOST_BASE_FROM_MEMBER_MAX_ARITY
\r
32 #define BOOST_BASE_FROM_MEMBER_MAX_ARITY 10
\r
36 // An iteration of a constructor template for base_from_member -------------//
\r
38 // A macro that should expand to:
\r
39 // template < typename T1, ..., typename Tn >
\r
40 // base_from_member( T1 x1, ..., Tn xn )
\r
41 // : member( x1, ..., xn )
\r
43 // This macro should only persist within this file.
\r
45 #define BOOST_PRIVATE_CTR_DEF( z, n, data ) \
\r
46 template < BOOST_PP_ENUM_PARAMS(n, typename T) > \
\r
47 explicit base_from_member( BOOST_PP_ENUM_BINARY_PARAMS(n, T, x) ) \
\r
48 : member( BOOST_PP_ENUM_PARAMS(n, x) ) \
\r
56 // Base-from-member class template -----------------------------------------//
\r
58 // Helper to initialize a base object so a derived class can use this
\r
59 // object in the initialization of another base class. Used by
\r
60 // Dietmar Kuehl from ideas by Ron Klatcho to solve the problem of a
\r
61 // base class needing to be initialized by a member.
\r
63 // Contributed by Daryle Walker
\r
65 template < typename MemberType, int UniqueID = 0 >
\r
66 class base_from_member
\r
75 BOOST_PP_REPEAT_FROM_TO( 1, BOOST_PP_INC(BOOST_BASE_FROM_MEMBER_MAX_ARITY),
\r
76 BOOST_PRIVATE_CTR_DEF, _ )
\r
78 }; // boost::base_from_member
\r
80 } // namespace boost
\r
83 // Undo any private macros
\r
84 #undef BOOST_PRIVATE_CTR_DEF
\r
87 #endif // BOOST_UTILITY_BASE_FROM_MEMBER_HPP
\r