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


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:45:07