annotate DEPENDENCIES/generic/include/boost/utility/base_from_member.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // boost utility/base_from_member.hpp header file --------------------------//
Chris@16 2
Chris@16 3 // Copyright 2001, 2003, 2004, 2012 Daryle Walker. Use, modification, and
Chris@16 4 // distribution are subject to the Boost Software License, Version 1.0. (See
Chris@16 5 // accompanying file LICENSE_1_0.txt or a copy at
Chris@16 6 // <http://www.boost.org/LICENSE_1_0.txt>.)
Chris@16 7
Chris@16 8 // See <http://www.boost.org/libs/utility/> for the library's home page.
Chris@16 9
Chris@16 10 #ifndef BOOST_UTILITY_BASE_FROM_MEMBER_HPP
Chris@16 11 #define BOOST_UTILITY_BASE_FROM_MEMBER_HPP
Chris@16 12
Chris@16 13 #include <boost/config.hpp>
Chris@16 14 #include <boost/preprocessor/arithmetic/inc.hpp>
Chris@16 15 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
Chris@16 16 #include <boost/preprocessor/repetition/enum_params.hpp>
Chris@16 17 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
Chris@16 18 #include <boost/type_traits/is_same.hpp>
Chris@16 19 #include <boost/type_traits/remove_cv.hpp>
Chris@16 20 #include <boost/type_traits/remove_reference.hpp>
Chris@16 21 #include <boost/utility/enable_if.hpp>
Chris@16 22
Chris@16 23
Chris@16 24 // Base-from-member arity configuration macro ------------------------------//
Chris@16 25
Chris@16 26 // The following macro determines how many arguments will be in the largest
Chris@16 27 // constructor template of base_from_member. Constructor templates will be
Chris@16 28 // generated from one argument to this maximum. Code from other files can read
Chris@16 29 // this number if they need to always match the exact maximum base_from_member
Chris@16 30 // uses. The maximum constructor length can be changed by overriding the
Chris@16 31 // #defined constant. Make sure to apply the override, if any, for all source
Chris@16 32 // files during project compiling for consistency.
Chris@16 33
Chris@16 34 // Contributed by Jonathan Turkanis
Chris@16 35
Chris@16 36 #ifndef BOOST_BASE_FROM_MEMBER_MAX_ARITY
Chris@16 37 #define BOOST_BASE_FROM_MEMBER_MAX_ARITY 10
Chris@16 38 #endif
Chris@16 39
Chris@16 40
Chris@16 41 // An iteration of a constructor template for base_from_member -------------//
Chris@16 42
Chris@16 43 // A macro that should expand to:
Chris@16 44 // template < typename T1, ..., typename Tn >
Chris@16 45 // base_from_member( T1 x1, ..., Tn xn )
Chris@16 46 // : member( x1, ..., xn )
Chris@16 47 // {}
Chris@16 48 // This macro should only persist within this file.
Chris@16 49
Chris@16 50 #define BOOST_PRIVATE_CTR_DEF( z, n, data ) \
Chris@16 51 template < BOOST_PP_ENUM_PARAMS(n, typename T) > \
Chris@16 52 explicit base_from_member( BOOST_PP_ENUM_BINARY_PARAMS(n, T, x) ) \
Chris@16 53 : member( BOOST_PP_ENUM_PARAMS(n, x) ) \
Chris@16 54 {} \
Chris@16 55 /**/
Chris@16 56
Chris@16 57
Chris@16 58 namespace boost
Chris@16 59 {
Chris@16 60
Chris@16 61 namespace detail
Chris@16 62 {
Chris@16 63
Chris@16 64 // Type-unmarking class template -------------------------------------------//
Chris@16 65
Chris@16 66 // Type-trait to get the raw type, i.e. the type without top-level reference nor
Chris@16 67 // cv-qualification, from a type expression. Mainly for function arguments, any
Chris@16 68 // reference part is stripped first.
Chris@16 69
Chris@16 70 // Contributed by Daryle Walker
Chris@16 71
Chris@16 72 template < typename T >
Chris@16 73 struct remove_cv_ref
Chris@16 74 {
Chris@16 75 typedef typename ::boost::remove_cv<typename
Chris@16 76 ::boost::remove_reference<T>::type>::type type;
Chris@16 77
Chris@16 78 }; // boost::detail::remove_cv_ref
Chris@16 79
Chris@16 80 // Unmarked-type comparison class template ---------------------------------//
Chris@16 81
Chris@16 82 // Type-trait to check if two type expressions have the same raw type.
Chris@16 83
Chris@16 84 // Contributed by Daryle Walker, based on a work-around by Luc Danton
Chris@16 85
Chris@16 86 template < typename T, typename U >
Chris@16 87 struct is_related
Chris@16 88 : public ::boost::is_same<
Chris@16 89 typename ::boost::detail::remove_cv_ref<T>::type,
Chris@16 90 typename ::boost::detail::remove_cv_ref<U>::type >
Chris@16 91 {};
Chris@16 92
Chris@16 93 // Enable-if-on-unidentical-unmarked-type class template -------------------//
Chris@16 94
Chris@16 95 // Enable-if on the first two type expressions NOT having the same raw type.
Chris@16 96
Chris@16 97 // Contributed by Daryle Walker, based on a work-around by Luc Danton
Chris@16 98
Chris@16 99 #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
Chris@16 100 template<typename ...T>
Chris@16 101 struct enable_if_unrelated
Chris@16 102 : public ::boost::enable_if_c<true>
Chris@16 103 {};
Chris@16 104
Chris@16 105 template<typename T, typename U, typename ...U2>
Chris@16 106 struct enable_if_unrelated<T, U, U2...>
Chris@16 107 : public ::boost::disable_if< ::boost::detail::is_related<T, U> >
Chris@16 108 {};
Chris@16 109 #endif
Chris@16 110
Chris@16 111 } // namespace boost::detail
Chris@16 112
Chris@16 113
Chris@16 114 // Base-from-member class template -----------------------------------------//
Chris@16 115
Chris@16 116 // Helper to initialize a base object so a derived class can use this
Chris@16 117 // object in the initialization of another base class. Used by
Chris@16 118 // Dietmar Kuehl from ideas by Ron Klatcho to solve the problem of a
Chris@16 119 // base class needing to be initialized by a member.
Chris@16 120
Chris@16 121 // Contributed by Daryle Walker
Chris@16 122
Chris@16 123 template < typename MemberType, int UniqueID = 0 >
Chris@16 124 class base_from_member
Chris@16 125 {
Chris@16 126 protected:
Chris@16 127 MemberType member;
Chris@16 128
Chris@16 129 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
Chris@16 130 !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
Chris@16 131 !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) && \
Chris@16 132 !(defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 4))
Chris@16 133 template <typename ...T, typename EnableIf = typename
Chris@16 134 ::boost::detail::enable_if_unrelated<base_from_member, T...>::type>
Chris@16 135 explicit BOOST_CONSTEXPR base_from_member( T&& ...x )
Chris@16 136 BOOST_NOEXCEPT_IF( BOOST_NOEXCEPT_EXPR(::new ((void*) 0) MemberType(
Chris@16 137 static_cast<T&&>(x)... )) ) // no std::is_nothrow_constructible...
Chris@16 138 : member( static_cast<T&&>(x)... ) // ...nor std::forward needed
Chris@16 139 {}
Chris@16 140 #else
Chris@16 141 base_from_member()
Chris@16 142 : member()
Chris@16 143 {}
Chris@16 144
Chris@16 145 BOOST_PP_REPEAT_FROM_TO( 1, BOOST_PP_INC(BOOST_BASE_FROM_MEMBER_MAX_ARITY),
Chris@16 146 BOOST_PRIVATE_CTR_DEF, _ )
Chris@16 147 #endif
Chris@16 148
Chris@16 149 }; // boost::base_from_member
Chris@16 150
Chris@101 151 template < typename MemberType, int UniqueID >
Chris@101 152 class base_from_member<MemberType&, UniqueID>
Chris@101 153 {
Chris@101 154 protected:
Chris@101 155 MemberType& member;
Chris@101 156
Chris@101 157 explicit BOOST_CONSTEXPR base_from_member( MemberType& x )
Chris@101 158 BOOST_NOEXCEPT
Chris@101 159 : member( x )
Chris@101 160 {}
Chris@101 161
Chris@101 162 }; // boost::base_from_member
Chris@101 163
Chris@16 164 } // namespace boost
Chris@16 165
Chris@16 166
Chris@16 167 // Undo any private macros
Chris@16 168 #undef BOOST_PRIVATE_CTR_DEF
Chris@16 169
Chris@16 170
Chris@16 171 #endif // BOOST_UTILITY_BASE_FROM_MEMBER_HPP