Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
value-type-binding.hpp File Reference

Type re-binding helper template for custom containers and adapters. More...

Go to the source code of this file.

Description

Type re-binding helper template for custom containers and adapters.

This header defines trait templates which are used by the Iterator adapters and similar custom containers to figure out the value-, pointer- and reference types when wrapping iterators or containers.

When writing a generic container or adapter, there is typically a point where you'll need some variation of the payload type: you may want to expose a reference, or you might need a pointer to the type, to implement a forwarding operator->(). On a technical level, this turns out surprisingly tricky, since we often don't know the exact "incantation" of the payload type and might thus end up forming a pointer to a rvalue reference or likewise illegal constructs.

Within the STL, there is a convention to provide nested typedefs to indicate type variations in relation to the basic payload type of the container. We follow this convention and support especially the

  • value_type (what is conceived to be "in" the container or iterator)
  • a simple (LValue) reference to the payload
  • a pointer at the payload.

A custom container should likewise provide such type definitions, and the type rebinding helper template defined in this header makes it easy to provide such nested type definitions in a flexible way. This usage also creates an Extension Point: when some payload type requires special treatment, an explicit specialisation to this rebinding trait may be injected alongside with the definition of the payload type.

The CommonResultYield type rebinding helper allows to reconcile several essentially compatible result types; it is used in iterator pipelines, especially for the case of child expansion, where some additional sub-sequences are to be integrated into a main sequence.

See also
ValueTypeBinding_test
iter-adapter.hpp
scope-path.hpp usage example (explicit specialisation)

Definition in file value-type-binding.hpp.

#include "lib/error.hpp"
#include "lib/meta/trait.hpp"

Namespaces

namespace  lib
 Implementation namespace for support and library code.
 
namespace  lib::meta
 
namespace  lib::meta::anonymous_namespace{value-type-binding.hpp}
 

Classes

class  has_nested_ValueTypeBindings< TY >
 
struct  has_nested_ValueTypeBindings< TY >::Probe< X, XX, XY, XZ >
 
struct  use_ValueTypebindings< X >
 
struct  ValueTypeBinding< TY, SEL >
 Type re-binding helper template for creating nested typedefs usable by custom containers and iterator adapters or similar. More...
 
struct  ValueTypeBinding< TY, enable_if< use_ValueTypebindings< TY > > >
 specialisation for classes providing STL style type binding definitions More...
 
struct  CommonResultYield< T1, T2, bool >
 Decision helper to select between returning results by value or reference. More...
 
struct  CommonResultYield< T1, T2, true >
 

Class Documentation

◆ lib::meta::anonymous_namespace{value-type-binding.hpp}::has_nested_ValueTypeBindings::Probe

struct lib::meta::anonymous_namespace{value-type-binding.hpp}::has_nested_ValueTypeBindings::Probe
+ Collaboration diagram for has_nested_ValueTypeBindings< TY >::Probe< X, XX, XY, XZ >:

◆ lib::meta::ValueTypeBinding

struct lib::meta::ValueTypeBinding
Class Members
typedef Value value_type
typedef Reference reference
typedef Pointer pointer
+ Collaboration diagram for ValueTypeBinding< TY, SEL >:

◆ lib::meta::ValueTypeBinding< TY, enable_if< use_ValueTypebindings< TY > > >

struct lib::meta::ValueTypeBinding< TY, enable_if< use_ValueTypebindings< TY > > >
Class Members
typedef Value _SrcType
typedef value_type value_type
typedef reference reference
typedef pointer pointer
+ Collaboration diagram for ValueTypeBinding< TY, enable_if< use_ValueTypebindings< TY > > >: