3.8.0
Freundlich's C++ toolkit
Public Types | Public Member Functions
fcppt::record::object< Elements > Class Template Reference

Detailed Description

template<typename... Elements>
class fcppt::record::object< Elements >

A generic struct that identifies elements by types.

A record of an MPL sequence fcppt::record::element element<L_1,T_1>,...,element<L_n,T_n> contains an object of type T_i, accessible by L_i, for every i = 1,...,n.

Template Parameters
ElementsEach one must be of type fcppt::record::element.

Public Types

using all_types = ::metal::list< Elements... >
 
using this_type = fcppt::record::object< Elements... >
 
using tuple = fcppt::metal::as_tuple< ::metal::transform<::metal::lambda< fcppt::record::element_to_type >, all_types > >
 The fcppt::tuple::object type (T_1,...,T_n). More...
 

Public Member Functions

 object ()
 Constructor for empty records. More...
 
 object (fcppt::no_init const &)
 An uninitialized record. More...
 
template<typename... Args, typename = fcppt::record::enable_vararg_ctor<Args...>>
 object (Args &&..._args)
 Generic constructor. More...
 
template<typename Label >
void set (fcppt::record::label_value_type< this_type, Label > const &)
 Sets an element by copy. More...
 
template<typename Label >
void set (fcppt::record::label_value_type< this_type, Label > &&)
 Sets an element by move. More...
 
template<typename Label >
fcppt::record::label_value_type< this_type, Label > const & get () const
 Gets an element. More...
 
template<typename Label >
fcppt::record::label_value_type< this_type, Label > & get ()
 Gets an element. More...
 
tuple const & impl () const
 

Member Typedef Documentation

◆ all_types

template<typename... Elements>
using fcppt::record::object< Elements >::all_types = ::metal::list<Elements...>

◆ this_type

template<typename... Elements>
using fcppt::record::object< Elements >::this_type = fcppt::record::object<Elements...>

◆ tuple

template<typename... Elements>
using fcppt::record::object< Elements >::tuple = fcppt::metal::as_tuple< ::metal::transform<::metal::lambda<fcppt::record::element_to_type>, all_types> >

The fcppt::tuple::object type (T_1,...,T_n).

Constructor & Destructor Documentation

◆ object() [1/3]

template<typename... Elements>
fcppt::record::object< Elements >::object ( )

Constructor for empty records.

Calling this if Elements is not empty, a compile-time error occurs.

◆ object() [2/3]

template<typename... Elements>
fcppt::record::object< Elements >::object ( fcppt::no_init const &  )
explicit

An uninitialized record.

Calls only default constructors for its elements. Use this with care.

◆ object() [3/3]

template<typename... Elements>
template<typename... Args, typename = fcppt::record::enable_vararg_ctor<Args...>>
fcppt::record::object< Elements >::object ( Args &&...  _args)
explicit

Generic constructor.

Initializing an element<L_i,T_i> is done by calling L_i{} = v_i where v_i is of type T_i.

The constructor checks that each L_i appears exactly once in Args.

Parameters
_argsA parameter pack, obtained by assignment to fcppt::record::label.
Template Parameters
ArgsImplementation-defined init types, obtained by assignment to fcppt::record::label.

Member Function Documentation

◆ get() [1/2]

template<typename... Elements>
template<typename Label >
fcppt::record::label_value_type<this_type, Label>& fcppt::record::object< Elements >::get ( )

Gets an element.

See also
fcppt::record::get.

◆ get() [2/2]

template<typename... Elements>
template<typename Label >
fcppt::record::label_value_type<this_type, Label> const& fcppt::record::object< Elements >::get ( ) const

Gets an element.

See also
fcppt::record::get.

◆ impl()

template<typename... Elements>
tuple const& fcppt::record::object< Elements >::impl ( ) const

◆ set() [1/2]

template<typename... Elements>
template<typename Label >
void fcppt::record::object< Elements >::set ( fcppt::record::label_value_type< this_type, Label > &&  )

Sets an element by move.

See also
fcppt::record::set.

◆ set() [2/2]

template<typename... Elements>
template<typename Label >
void fcppt::record::object< Elements >::set ( fcppt::record::label_value_type< this_type, Label > const &  )

Sets an element by copy.

See also
fcppt::record::set.