raberu v1.1.0
Fancy Named Parameter Library
 
Loading...
Searching...
No Matches

◆ accept()

static constexpr bool rbr::as_keyword< typed_keyword< ID, Type > >::accept ( )
inlinestaticconstexprinherited

Compile-time validation of value.

When a value is bound to a Keyword to form an Option, one can validate this binding by checking arbitrary properties on the value type. This is done by the accept() member.

If Keyword defines a check static template member function, it will be called to provide the return value of accept(). Otherwise, true is returned, thus automatically validating any value type.

Template Parameters
TType to validate
Returns
true if T is accepted by current keyword, false otherwise.

Example:

#include <raberu/raberu.hpp>
// Defines a keyword type that only accept floating point value
struct real_keyword : rbr::as_keyword<real_keyword>
{
template<typename T> static constexpr bool check() { return std::is_floating_point_v<T>; }
using rbr::as_keyword<real_keyword>::operator=;
};
inline constexpr real_keyword real = {};
Base class for keyword definition.
Definition: keywords.hpp:62