cli20 0.1.2
A C++20 typed-schema command-line parser
Loading...
Searching...
No Matches
cli::conversion::Choice< T, Mapper > Struct Template Reference

Converts a string token to type T via a user-supplied mapper function. More...

#include <action.hh>

Public Types

template<class Input>
using after_type = T
template<class Prev>
using storage_type = void

Public Member Functions

auto operator() (ActionCtx< void > ctx, ActionResult< std::string_view > input) const -> ActionResult< T >

Static Public Attributes

template<class Input>
static constexpr bool accepts_input = Bool::template accepts_input<Input>

Detailed Description

template<class T, auto Mapper>
struct cli::conversion::Choice< T, Mapper >

Converts a string token to type T via a user-supplied mapper function.

Mapper must be a constexpr callable of the form (std::string_view) -> std::optional<T>. Returns ErrorCode::invalid_choice when the mapper returns std::nullopt.

Template Parameters
TThe target value type.
MapperA constexpr callable mapping strings to std::optional<T>.

Definition at line 895 of file action.hh.

Member Typedef Documentation

◆ after_type

template<class T, auto Mapper>
template<class Input>
using cli::conversion::Choice< T, Mapper >::after_type = T

Definition at line 900 of file action.hh.

◆ storage_type

template<class T, auto Mapper>
template<class Prev>
using cli::conversion::Choice< T, Mapper >::storage_type = void

Definition at line 903 of file action.hh.

Member Function Documentation

◆ operator()()

template<class T, auto Mapper>
auto cli::conversion::Choice< T, Mapper >::operator() ( ActionCtx< void > ctx,
ActionResult< std::string_view > input ) const -> ActionResult< T >
inline

Definition at line 905 of file action.hh.

Member Data Documentation

◆ accepts_input

template<class T, auto Mapper>
template<class Input>
bool cli::conversion::Choice< T, Mapper >::accepts_input = Bool::template accepts_input<Input>
staticconstexpr

Definition at line 897 of file action.hh.


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