tclap 1.6.0
Public Types | Public Member Functions | List of all members
TCLAP::PredicateConstraint< T, Function, Text > Class Template Reference

Adapts an owned function or const function object to Constraint<T>. More...

#include <PredicateConstraint.h>

Inheritance diagram for TCLAP::PredicateConstraint< T, Function, Text >:
Inheritance graph
[legend]
Collaboration diagram for TCLAP::PredicateConstraint< T, Function, Text >:
Collaboration graph
[legend]

Public Types

using Predicate = Function
 

Public Member Functions

template<class F >
requires std::constructible_from<Function, F &&> && std::constructible_from<Text, std::string, std::string>
 PredicateConstraint (std::string description, std::string shortId, F &&function)
 Owns the callable and separate presentation strings.
 
template<class F >
requires std::constructible_from<Function, F &&>
 PredicateConstraint (F &&function, Text text)
 Advanced form used by the rule factory to share validation/text state.
 
 PredicateConstraint (const PredicateConstraint &)=default
 
 PredicateConstraint (PredicateConstraint &&)=default
 
PredicateConstraint & operator= (const PredicateConstraint &)=default
 
PredicateConstraint & operator= (PredicateConstraint &&)=default
 
 ~PredicateConstraint () override=default
 
bool check (const T &value) const override
 The method used to verify that the value parsed from the command line meets the constraint.
 
std::string description () const override
 Returns a description of the Constraint.
 
std::string shortID () const override
 Returns the short ID for the Constraint.
 
- Public Member Functions inherited from TCLAP::Constraint< T >
virtual ~Constraint ()=default
 Destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from TCLAP::Constraint< T >
static std::string shortID (const Constraint< T > *constraint)
 

Detailed Description

template<class T, class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
requires internal::ConstraintPredicate<T, Function, Text>
class TCLAP::PredicateConstraint< T, Function, Text >

Adapts an owned function or const function object to Constraint<T>.

Function must accept const T& and return a value convertible to bool. The adapter copies lvalues and moves rvalues; explicitly borrowed state inside it must remain alive. Args borrow the constraint itself: declare it before the arguments using it and do not move it after binding its address. Null function/member pointers and empty std::function objects are rejected with std::invalid_argument. Exceptions from the callable or text policy propagate unchanged from these methods.

MakeConstraint() deduces Function. MakeRuleConstraint() also obtains description()/shortID() from the same stored callable. Ordinary callers supply separate description and short-ID strings and need no text policy.

Definition at line 124 of file PredicateConstraint.h.

Member Typedef Documentation

◆ Predicate

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
using TCLAP::PredicateConstraint< T, Function, Text >::Predicate = Function

Definition at line 126 of file PredicateConstraint.h.

Constructor & Destructor Documentation

◆ PredicateConstraint() [1/4]

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
template<class F >
requires std::constructible_from<Function, F &&> && std::constructible_from<Text, std::string, std::string>
TCLAP::PredicateConstraint< T, Function, Text >::PredicateConstraint ( std::string  description,
std::string  shortId,
F &&  function 
)
inline

Owns the callable and separate presentation strings.

Definition at line 132 of file PredicateConstraint.h.

References TCLAP::internal::ValidateConstraintPredicate().

Here is the call graph for this function:

◆ PredicateConstraint() [2/4]

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
template<class F >
requires std::constructible_from<Function, F &&>
TCLAP::PredicateConstraint< T, Function, Text >::PredicateConstraint ( F &&  function,
Text  text 
)
inline

Advanced form used by the rule factory to share validation/text state.

Definition at line 143 of file PredicateConstraint.h.

References TCLAP::internal::ValidateConstraintPredicate().

Here is the call graph for this function:

◆ PredicateConstraint() [3/4]

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
TCLAP::PredicateConstraint< T, Function, Text >::PredicateConstraint ( const PredicateConstraint< T, Function, Text > &  )
default

◆ PredicateConstraint() [4/4]

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
TCLAP::PredicateConstraint< T, Function, Text >::PredicateConstraint ( PredicateConstraint< T, Function, Text > &&  )
default

◆ ~PredicateConstraint()

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
TCLAP::PredicateConstraint< T, Function, Text >::~PredicateConstraint ( )
overridedefault

Member Function Documentation

◆ check()

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
bool TCLAP::PredicateConstraint< T, Function, Text >::check ( const T &  value) const
inlineoverridevirtual

The method used to verify that the value parsed from the command line meets the constraint.

Parameters
value- The value that will be checked.

Implements TCLAP::Constraint< T >.

Definition at line 154 of file PredicateConstraint.h.

◆ description()

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
std::string TCLAP::PredicateConstraint< T, Function, Text >::description ( ) const
inlineoverridevirtual

Returns a description of the Constraint.

Implements TCLAP::Constraint< T >.

Definition at line 157 of file PredicateConstraint.h.

◆ operator=() [1/2]

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
PredicateConstraint & TCLAP::PredicateConstraint< T, Function, Text >::operator= ( const PredicateConstraint< T, Function, Text > &  )
default

◆ operator=() [2/2]

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
PredicateConstraint & TCLAP::PredicateConstraint< T, Function, Text >::operator= ( PredicateConstraint< T, Function, Text > &&  )
default

◆ shortID()

template<class T , class Function = std::function<bool(const T &)>, class Text = internal::FixedConstraintText>
std::string TCLAP::PredicateConstraint< T, Function, Text >::shortID ( ) const
inlineoverridevirtual

Returns the short ID for the Constraint.

Implements TCLAP::Constraint< T >.

Definition at line 160 of file PredicateConstraint.h.


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