Lumiera  0.pre.03
»edit your freedom«
value-type-binding.hpp File Reference

Go to the source code of this file.

Description

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

This header defines a trait template which is 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.

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"

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...
 

Namespaces

 lib
 Implementation namespace for support and library code.
 

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 >: