ModErn Text Analysis
META Enumerates Textual Applications
Public Member Functions | Public Attributes | Friends | List of all members
meta::util::identifier< Derived, T > Struct Template Reference

CRTP base template that denotes an identifier. More...

#include <identifiers.h>

Inheritance diagram for meta::util::identifier< Derived, T >:
meta::util::comparable< identifier< Derived, T > > meta::util::numerical_identifier< Derived, T >

Public Member Functions

 identifier (const T &t)
 identifiers must be explicitly constructed from their base type—they cannot be implicitly converted from them! More...
 
 identifier ()=default
 identifier has a default constructor.
 
 identifier (const identifier &)=default
 identifiers may be copy constructed.
 
 identifier (identifier &&)=default
 identifiers may be move constructed.
 
identifieroperator= (const identifier &)=default
 identifiers may be copy assigned.
 
identifieroperator= (identifier &&)=default
 identifiers may be move assigned.
 
identifieroperator= (const T &t)
 identifiers may be assigned into from their base type, provided they have already been constructed. More...
 
 operator const T & () const
 identifiers may be converted into their base type. More...
 
 operator T & ()
 identifiers may be converted into their base type. More...
 

Public Attributes

id_
 The underlying id for the identifier.
 

Friends

bool operator< (const identifier &lhs, const identifier &rhs)
 identifiers are comparable by their base types. More...
 
std::ostream & operator<< (std::ostream &stream, const identifier &ident)
 identifiers may be printed to output streams. More...
 
std::istream & operator>> (std::istream &stream, identifier &ident)
 identifiers may be read from input streams. More...
 

Detailed Description

template<class Derived, class T>
struct meta::util::identifier< Derived, T >

CRTP base template that denotes an identifier.

identifiers are comparable through normal relational operators defined on the underlying type T.

Constructor & Destructor Documentation

template<class Derived , class T >
meta::util::identifier< Derived, T >::identifier ( const T &  t)
inlineexplicit

identifiers must be explicitly constructed from their base type—they cannot be implicitly converted from them!

Parameters
tthe underlying type to convert into an identifier

Member Function Documentation

template<class Derived , class T >
identifier& meta::util::identifier< Derived, T >::operator= ( const T &  t)
inline

identifiers may be assigned into from their base type, provided they have already been constructed.

Example:

my_ident x{1};
x = 2; // fine
my_ident y = 1; // not fine, compiler error
Parameters
tThe base type to assign into the identifier
Returns
the current identifier
template<class Derived , class T >
meta::util::identifier< Derived, T >::operator const T & ( ) const
inline

identifiers may be converted into their base type.

This is the const version.

Returns
the base type representation for this identifier
template<class Derived , class T >
meta::util::identifier< Derived, T >::operator T & ( )
inline

identifiers may be converted into their base type.

This is the non-const version.

Returns
the base type representation for this identifier

Friends And Related Function Documentation

template<class Derived , class T >
bool operator< ( const identifier< Derived, T > &  lhs,
const identifier< Derived, T > &  rhs 
)
friend

identifiers are comparable by their base types.

This allows for storage in comparison-based containers like std::map or std::set.

Parameters
lhs
rhs
Returns
whether lhs < rhs based on T::operator<.
template<class Derived , class T >
std::ostream& operator<< ( std::ostream &  stream,
const identifier< Derived, T > &  ident 
)
friend

identifiers may be printed to output streams.

Parameters
streamThe stream to write to
identThe identifier to write to the stream
Returns
stream
template<class Derived , class T >
std::istream& operator>> ( std::istream &  stream,
identifier< Derived, T > &  ident 
)
friend

identifiers may be read from input streams.

Parameters
streamThe stream to read from
identThe identifier to read into
Returns
stream

The documentation for this struct was generated from the following file: