epoc32/include/stdapis/boost/utility/base_from_member.hpp
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
//  boost utility/base_from_member.hpp header file  --------------------------//
williamr@2
     2
williamr@2
     3
//  Copyright 2001, 2003, 2004 Daryle Walker.  Use, modification, and
williamr@2
     4
//  distribution are subject to the Boost Software License, Version 1.0.  (See
williamr@2
     5
//  accompanying file LICENSE_1_0.txt or a copy at
williamr@2
     6
//  <http://www.boost.org/LICENSE_1_0.txt>.)
williamr@2
     7
williamr@2
     8
//  See <http://www.boost.org/libs/utility/> for the library's home page.
williamr@2
     9
williamr@2
    10
#ifndef BOOST_UTILITY_BASE_FROM_MEMBER_HPP
williamr@2
    11
#define BOOST_UTILITY_BASE_FROM_MEMBER_HPP
williamr@2
    12
williamr@2
    13
#include <boost/preprocessor/arithmetic/inc.hpp>
williamr@2
    14
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
williamr@2
    15
#include <boost/preprocessor/repetition/enum_params.hpp>
williamr@2
    16
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
williamr@2
    17
williamr@2
    18
williamr@2
    19
//  Base-from-member arity configuration macro  ------------------------------//
williamr@2
    20
williamr@2
    21
// The following macro determines how many arguments will be in the largest
williamr@2
    22
// constructor template of base_from_member.  Constructor templates will be
williamr@2
    23
// generated from one argument to this maximum.  Code from other files can read
williamr@2
    24
// this number if they need to always match the exact maximum base_from_member
williamr@2
    25
// uses.  The maximum constructor length can be changed by overriding the
williamr@2
    26
// #defined constant.  Make sure to apply the override, if any, for all source
williamr@2
    27
// files during project compiling for consistency.
williamr@2
    28
williamr@2
    29
// Contributed by Jonathan Turkanis
williamr@2
    30
williamr@2
    31
#ifndef BOOST_BASE_FROM_MEMBER_MAX_ARITY
williamr@2
    32
#define BOOST_BASE_FROM_MEMBER_MAX_ARITY  10
williamr@2
    33
#endif
williamr@2
    34
williamr@2
    35
williamr@2
    36
//  An iteration of a constructor template for base_from_member  -------------//
williamr@2
    37
williamr@2
    38
// A macro that should expand to:
williamr@2
    39
//     template < typename T1, ..., typename Tn >
williamr@2
    40
//     base_from_member( T1 x1, ..., Tn xn )
williamr@2
    41
//         : member( x1, ..., xn )
williamr@2
    42
//         {}
williamr@2
    43
// This macro should only persist within this file.
williamr@2
    44
williamr@2
    45
#define BOOST_PRIVATE_CTR_DEF( z, n, data )                            \
williamr@2
    46
    template < BOOST_PP_ENUM_PARAMS(n, typename T) >                   \
williamr@2
    47
    explicit base_from_member( BOOST_PP_ENUM_BINARY_PARAMS(n, T, x) )  \
williamr@2
    48
        : member( BOOST_PP_ENUM_PARAMS(n, x) )                         \
williamr@2
    49
        {}                                                             \
williamr@2
    50
    /**/
williamr@2
    51
williamr@2
    52
williamr@2
    53
namespace boost
williamr@2
    54
{
williamr@2
    55
williamr@2
    56
//  Base-from-member class template  -----------------------------------------//
williamr@2
    57
williamr@2
    58
// Helper to initialize a base object so a derived class can use this
williamr@2
    59
// object in the initialization of another base class.  Used by
williamr@2
    60
// Dietmar Kuehl from ideas by Ron Klatcho to solve the problem of a
williamr@2
    61
// base class needing to be initialized by a member.
williamr@2
    62
williamr@2
    63
// Contributed by Daryle Walker
williamr@2
    64
williamr@2
    65
template < typename MemberType, int UniqueID = 0 >
williamr@2
    66
class base_from_member
williamr@2
    67
{
williamr@2
    68
protected:
williamr@2
    69
    MemberType  member;
williamr@2
    70
williamr@2
    71
    base_from_member()
williamr@2
    72
        : member()
williamr@2
    73
        {}
williamr@2
    74
williamr@2
    75
    BOOST_PP_REPEAT_FROM_TO( 1, BOOST_PP_INC(BOOST_BASE_FROM_MEMBER_MAX_ARITY),
williamr@2
    76
     BOOST_PRIVATE_CTR_DEF, _ )
williamr@2
    77
williamr@2
    78
};  // boost::base_from_member
williamr@2
    79
williamr@2
    80
}  // namespace boost
williamr@2
    81
williamr@2
    82
williamr@2
    83
// Undo any private macros
williamr@2
    84
#undef BOOST_PRIVATE_CTR_DEF
williamr@2
    85
williamr@2
    86
williamr@2
    87
#endif  // BOOST_UTILITY_BASE_FROM_MEMBER_HPP