00001 // boost utility/base_from_member.hpp header file --------------------------// 00002 00003 // Copyright 2001, 2003, 2004 Daryle Walker. Use, modification, and 00004 // distribution are subject to the Boost Software License, Version 1.0. (See 00005 // accompanying file LICENSE_1_0.txt or a copy at 00006 // <http://www.boost.org/LICENSE_1_0.txt>.) 00007 00008 // See <http://www.boost.org/libs/utility/> for the library's home page. 00009 00010 #ifndef BOOST_UTILITY_BASE_FROM_MEMBER_HPP 00011 #define BOOST_UTILITY_BASE_FROM_MEMBER_HPP 00012 00013 #include <sysc/packages/boost/preprocessor/arithmetic/inc.hpp> 00014 #include <sysc/packages/boost/preprocessor/repetition/enum_binary_params.hpp> 00015 #include <sysc/packages/boost/preprocessor/repetition/enum_params.hpp> 00016 #include <sysc/packages/boost/preprocessor/repetition/repeat_from_to.hpp> 00017 00018 00019 // Base-from-member arity configuration macro ------------------------------// 00020 00021 // The following macro determines how many arguments will be in the largest 00022 // constructor template of base_from_member. Constructor templates will be 00023 // generated from one argument to this maximum. Code from other files can read 00024 // this number if they need to always match the exact maximum base_from_member 00025 // uses. The maximum constructor length can be changed by overriding the 00026 // #defined constant. Make sure to apply the override, if any, for all source 00027 // files during project compiling for consistency. 00028 00029 // Contributed by Jonathan Turkanis 00030 00031 #ifndef BOOST_BASE_FROM_MEMBER_MAX_ARITY 00032 #define BOOST_BASE_FROM_MEMBER_MAX_ARITY 10 00033 #endif 00034 00035 00036 // An iteration of a constructor template for base_from_member -------------// 00037 00038 // A macro that should expand to: 00039 // template < typename T1, ..., typename Tn > 00040 // base_from_member( T1 x1, ..., Tn xn ) 00041 // : member( x1, ..., xn ) 00042 // {} 00043 // This macro should only persist within this file. 00044 00045 #define BOOST_PRIVATE_CTR_DEF( z, n, data ) \ 00046 template < BOOST_PP_ENUM_PARAMS(n, typename T) > \ 00047 explicit base_from_member( BOOST_PP_ENUM_BINARY_PARAMS(n, T, x) ) \ 00048 : member( BOOST_PP_ENUM_PARAMS(n, x) ) \ 00049 {} \ 00050 /**/ 00051 00052 00053 namespace boost 00054 { 00055 00056 // Base-from-member class template -----------------------------------------// 00057 00058 // Helper to initialize a base object so a derived class can use this 00059 // object in the initialization of another base class. Used by 00060 // Dietmar Kuehl from ideas by Ron Klatcho to solve the problem of a 00061 // base class needing to be initialized by a member. 00062 00063 // Contributed by Daryle Walker 00064 00065 template < typename MemberType, int UniqueID = 0 > 00066 class base_from_member 00067 { 00068 protected: 00069 MemberType member; 00070 00071 base_from_member() 00072 : member() 00073 {} 00074 00075 BOOST_PP_REPEAT_FROM_TO( 1, BOOST_PP_INC(BOOST_BASE_FROM_MEMBER_MAX_ARITY), 00076 BOOST_PRIVATE_CTR_DEF, _ ) 00077 00078 }; // boost::base_from_member 00079 00080 } // namespace boost 00081 00082 00083 // Undo any private macros 00084 #undef BOOST_PRIVATE_CTR_DEF 00085 00086 00087 #endif // BOOST_UTILITY_BASE_FROM_MEMBER_HPP
1.5.5