Lumiera  0.pre.03
»edit your freedom«
value-type-binding.hpp
Go to the documentation of this file.
1 /*
2  VALUE-TYPE-BINDING.hpp - control type variations for custom containers
3 
4  Copyright (C) Lumiera.org
5  2010, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
56 #ifndef LIB_META_VALUE_TYPE_BINDING_H
57 #define LIB_META_VALUE_TYPE_BINDING_H
58 
59 
60 #include "lib/error.hpp"
61 #include "lib/meta/trait.hpp"
62 
63 
64 
65 
66 namespace lib {
67 namespace meta {
68 
69  namespace { // Helper trait to detect nested value_type binding definitions
70 
71  template<typename TY>
73  {
74  template<typename X, typename XX = typename X::value_type
75  , typename XY = typename X::reference
76  , typename XZ = typename X::pointer
77  >
78  struct Probe
79  { };
80 
81  template<class X>
82  static Yes_t check(Probe<X> * );
83  template<class>
84  static No_t check(...);
85 
86  public:
87  static const bool value = (sizeof(Yes_t)==sizeof(check<TY>(0)));
88  };
89 
90  template<class X>
92  : __and_<has_nested_ValueTypeBindings< remove_reference_t<X> >
93  ,__not_<is_StringLike< remove_reference_t<X> >
94  >
95  >
96  { };
97  }
98 
99 
111  template<typename TY, typename SEL =void>
113  {
114  using value_type = typename RefTraits<TY>::Value;
115  using reference = typename RefTraits<TY>::Reference;
116  using pointer = typename RefTraits<TY>::Pointer;
117  };
118 
120  template<typename TY>
121  struct ValueTypeBinding<TY, enable_if<use_ValueTypebindings<TY>> >
122  {
123  using _SrcType = typename RefTraits<TY>::Value;
124 
125  using value_type = typename _SrcType::value_type;
126  using reference = typename _SrcType::reference;
127  using pointer = typename _SrcType::pointer;
128  };
129 
130 
131 
132 }} // namespace lib::meta
133 #endif /*LIB_META_VALUE_TYPE_BINDING_H*/
Representation of the result of some operation, EITHER a value or a failure.
Definition: result.hpp:106
Implementation namespace for support and library code.
typename enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition: meta/util.hpp:91
char Yes_t
helper types to detect the overload resolution chosen by the compiler
Definition: meta/util.hpp:103
Helpers for type detection, type rewriting and metaprogramming.
Lumiera error handling (C++ interface).
Type re-binding helper template for creating nested typedefs usable by custom containers and iterator...