Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
OptionalArg< Decl, Specifier, TArgs... > Class Template Reference

Template recursion entry. More...

#include <OptionalArgs.hxx>

Inheritance diagram for OptionalArg< Decl, Specifier, TArgs... >:
OptionalArg< Decl, TArgs... >

Public Types

typedef Specifier specifier_type
 This is the type used by the customer to set the value in the initializer list.
 
typedef Specifier::FetcherType fetcher_type
 This is the type we use internally to tag and fetch the value.
 
typedef Specifier::data_type data_type
 The type of the actually stored data. Should be POD.
 
using Base = OptionalArg< Decl, TArgs... >
 Recursion, with all other arguments.
 

Public Member Functions

template<typename... Args>
constexpr OptionalArg (Args... args)
 Constructor.
 
constexpr OptionalArg ()
 Constructor ending the recursion.
 
constexpr data_type get (const fetcher_type) const
 
constexpr bool has (const fetcher_type) const
 

Static Private Member Functions

template<typename... Args>
static constexpr data_type GetFromArgs (const specifier_type spec, Args... args)
 This template gets instantiated when the first argument is for us.
 
template<typename... Args>
static constexpr bool HasFromArgs (const specifier_type spec, Args... args)
 Decides whether we have the current argument (from the original list or arguments).
 
template<typename U , typename... Args>
static constexpr std::enable_if< std::is_convertible< typenamestd::add_lvalue_reference< U >::type, typenamestd::add_lvalue_reference< Base >::type >::value, data_type >::type GetFromArgs (const U me, Args... args)
 This template gets instantiated for a copy constructor: when the argument is already an OptionalArg (or reference to it).
 
template<typename U , typename... Args>
static constexpr std::enable_if< std::is_convertible< typenamestd::add_lvalue_reference< U >::type, typenamestd::add_lvalue_reference< Base >::type >::value, bool >::type HasFromArgs (const U me, Args... args)
 This template gets instantiated for a copy constructor: when the argument is already an OptionalArg (or reference to it).
 
template<typename T , typename... Args>
static constexpr std::enable_if<!std::is_convertible< typenamestd::add_lvalue_reference< T >::type, typenamestd::add_lvalue_reference< Base >::type >::value, data_type >::type GetFromArgs (const T t, Args... args)
 This template gets instantiated only if the argument is not an OptionalArg (hence not called from the copy constructor) and not a Specifier for the current entry.
 
template<typename T , typename... Args>
static constexpr std::enable_if<!std::is_convertible< typenamestd::add_lvalue_reference< T >::type, typenamestd::add_lvalue_reference< Base >::type >::value, bool >::type HasFromArgs (const T t, Args... args)
 This template gets instantiated only if the argument is not an OptionalArg (hence not called from the copy constructor) and not a Specifier for the current entry.
 
static constexpr data_type GetFromArgs ()
 If we've run out of all arguments, we take the default value.
 
static constexpr bool HasFromArgs ()
 If we've run out of all arguments, there is no specifier.
 

Private Attributes

data_type d_
 Data that the user specified (or the default).
 
bool has_
 Whether the user has specified the value or not.
 

Detailed Description

template<typename Decl, typename Specifier, typename... TArgs>
class OptionalArg< Decl, Specifier, TArgs... >

Template recursion entry.

We have as many instances of this class in the inheritance stack as the number of data elements we need to carry. Each of these classes stores one single element in the private variable d_.

The constructor picks out the specifier for the current entry to fill in the current storage. All arguments are forwarded to the base class. This allows arbitrary order of the specified arguments; it is the responsibility of the innermost class to check for spurious arguments.

The get method either recognizes the Fetcher argument as referring to the current entry, or forwards it to the parent class.

Definition at line 187 of file OptionalArgs.hxx.

Member Typedef Documentation

◆ Base

template<typename Decl , typename Specifier , typename... TArgs>
using OptionalArg< Decl, Specifier, TArgs... >::Base = OptionalArg<Decl, TArgs...>

Recursion, with all other arguments.

Definition at line 199 of file OptionalArgs.hxx.

◆ data_type

template<typename Decl , typename Specifier , typename... TArgs>
typedef Specifier::data_type OptionalArg< Decl, Specifier, TArgs... >::data_type

The type of the actually stored data. Should be POD.

Definition at line 197 of file OptionalArgs.hxx.

◆ fetcher_type

template<typename Decl , typename Specifier , typename... TArgs>
typedef Specifier::FetcherType OptionalArg< Decl, Specifier, TArgs... >::fetcher_type

This is the type we use internally to tag and fetch the value.

Definition at line 195 of file OptionalArgs.hxx.

◆ specifier_type

template<typename Decl , typename Specifier , typename... TArgs>
typedef Specifier OptionalArg< Decl, Specifier, TArgs... >::specifier_type

This is the type used by the customer to set the value in the initializer list.

Definition at line 193 of file OptionalArgs.hxx.

Constructor & Destructor Documentation

◆ OptionalArg() [1/2]

template<typename Decl , typename Specifier , typename... TArgs>
template<typename... Args>
constexpr OptionalArg< Decl, Specifier, TArgs... >::OptionalArg ( Args...  args)
inlineconstexpr

Constructor.

Parameters
argsspecifies the values to store.

Definition at line 203 of file OptionalArgs.hxx.

◆ OptionalArg() [2/2]

template<typename Decl , typename Specifier , typename... TArgs>
constexpr OptionalArg< Decl, Specifier, TArgs... >::OptionalArg ( )
inlineconstexpr

Constructor ending the recursion.

Definition at line 211 of file OptionalArgs.hxx.

Member Function Documentation

◆ get()

template<typename Decl , typename Specifier , typename... TArgs>
constexpr data_type OptionalArg< Decl, Specifier, TArgs... >::get ( const fetcher_type  ) const
inlineconstexpr
Returns
the data stored.

Definition at line 218 of file OptionalArgs.hxx.

◆ GetFromArgs() [1/4]

template<typename Decl , typename Specifier , typename... TArgs>
static constexpr data_type OptionalArg< Decl, Specifier, TArgs... >::GetFromArgs ( )
inlinestaticconstexprprivate

If we've run out of all arguments, we take the default value.

Definition at line 304 of file OptionalArgs.hxx.

◆ GetFromArgs() [2/4]

template<typename Decl , typename Specifier , typename... TArgs>
template<typename... Args>
static constexpr data_type OptionalArg< Decl, Specifier, TArgs... >::GetFromArgs ( const specifier_type  spec,
Args...  args 
)
inlinestaticconstexprprivate

This template gets instantiated when the first argument is for us.

Definition at line 237 of file OptionalArgs.hxx.

◆ GetFromArgs() [3/4]

template<typename Decl , typename Specifier , typename... TArgs>
template<typename T , typename... Args>
static constexpr std::enable_if<!std::is_convertible< typenamestd::add_lvalue_reference< T >::type, typenamestd::add_lvalue_reference< Base >::type >::value, data_type >::type OptionalArg< Decl, Specifier, TArgs... >::GetFromArgs ( const T  t,
Args...  args 
)
inlinestaticconstexprprivate

This template gets instantiated only if the argument is not an OptionalArg (hence not called from the copy constructor) and not a Specifier for the current entry.

Then we just ignore the first arg and recurse into the rest of them.

Parameters
tis the argument to ignore.
argsare the further arguments.

Definition at line 285 of file OptionalArgs.hxx.

◆ GetFromArgs() [4/4]

template<typename Decl , typename Specifier , typename... TArgs>
template<typename U , typename... Args>
static constexpr std::enable_if< std::is_convertible< typenamestd::add_lvalue_reference< U >::type, typenamestd::add_lvalue_reference< Base >::type >::value, data_type >::type OptionalArg< Decl, Specifier, TArgs... >::GetFromArgs ( const U  me,
Args...  args 
)
inlinestaticconstexprprivate

This template gets instantiated for a copy constructor: when the argument is already an OptionalArg (or reference to it).

Parameters
meis the copy constructor argument.
argsare the further arguments.

Definition at line 259 of file OptionalArgs.hxx.

◆ has()

template<typename Decl , typename Specifier , typename... TArgs>
constexpr bool OptionalArg< Decl, Specifier, TArgs... >::has ( const fetcher_type  ) const
inlineconstexpr
Returns
whether we have stored data or only the default.

Definition at line 224 of file OptionalArgs.hxx.

◆ HasFromArgs() [1/4]

template<typename Decl , typename Specifier , typename... TArgs>
static constexpr bool OptionalArg< Decl, Specifier, TArgs... >::HasFromArgs ( )
inlinestaticconstexprprivate

If we've run out of all arguments, there is no specifier.

Definition at line 309 of file OptionalArgs.hxx.

◆ HasFromArgs() [2/4]

template<typename Decl , typename Specifier , typename... TArgs>
template<typename... Args>
static constexpr bool OptionalArg< Decl, Specifier, TArgs... >::HasFromArgs ( const specifier_type  spec,
Args...  args 
)
inlinestaticconstexprprivate

Decides whether we have the current argument (from the original list or arguments).

Returns
true if we have specified the argument.

Definition at line 246 of file OptionalArgs.hxx.

◆ HasFromArgs() [3/4]

template<typename Decl , typename Specifier , typename... TArgs>
template<typename T , typename... Args>
static constexpr std::enable_if<!std::is_convertible< typenamestd::add_lvalue_reference< T >::type, typenamestd::add_lvalue_reference< Base >::type >::value, bool >::type OptionalArg< Decl, Specifier, TArgs... >::HasFromArgs ( const T  t,
Args...  args 
)
inlinestaticconstexprprivate

This template gets instantiated only if the argument is not an OptionalArg (hence not called from the copy constructor) and not a Specifier for the current entry.

Then we just ignore the first arg and recurse into the rest of them.

Definition at line 298 of file OptionalArgs.hxx.

◆ HasFromArgs() [4/4]

template<typename Decl , typename Specifier , typename... TArgs>
template<typename U , typename... Args>
static constexpr std::enable_if< std::is_convertible< typenamestd::add_lvalue_reference< U >::type, typenamestd::add_lvalue_reference< Base >::type >::value, bool >::type OptionalArg< Decl, Specifier, TArgs... >::HasFromArgs ( const U  me,
Args...  args 
)
inlinestaticconstexprprivate

This template gets instantiated for a copy constructor: when the argument is already an OptionalArg (or reference to it).

Definition at line 270 of file OptionalArgs.hxx.

Member Data Documentation

◆ d_

template<typename Decl , typename Specifier , typename... TArgs>
data_type OptionalArg< Decl, Specifier, TArgs... >::d_
private

Data that the user specified (or the default).

Definition at line 315 of file OptionalArgs.hxx.

◆ has_

template<typename Decl , typename Specifier , typename... TArgs>
bool OptionalArg< Decl, Specifier, TArgs... >::has_
private

Whether the user has specified the value or not.

Definition at line 317 of file OptionalArgs.hxx.


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