CPP-AP 2.2.6
Command-line argument parser for C++20
Loading...
Searching...
No Matches
utility.hpp
Go to the documentation of this file.
1// Copyright (c) 2023-2025 Jakub MusiaƂ
2// This file is part of the CPP-AP project (https://github.com/SpectraL519/cpp-ap).
3// Licensed under the MIT License. See the LICENSE file in the project root for full license information.
4
10#pragma once
11
13
14#include <utility>
15#include <variant>
16
17namespace ap::action::detail {
18
23template <typename AS>
26
31template <typename AS>
32concept c_action_specifier = c_value_action_specifier<AS> or std::same_as<AS, action_type::on_flag>;
33
35template <c_value_action_specifier AS, ap::detail::c_argument_value_type T>
36using callable_type = typename AS::template type<T>;
37
39template <ap::detail::c_argument_value_type T>
40using value_action_variant_type = std::variant<
44
49template <ap::detail::c_argument_value_type T>
51 using value_type = T;
52
58 action(std::as_const(value));
59 }
60
66 value = action(std::as_const(value));
67 }
68
74 action(value);
75 }
76
77 value_type& value;
78};
79
80} // namespace ap::action::detail
The concept is satisfied when AS is a valid action action specifier.
Definition utility.hpp:32
The concept is satisfied when AS is a valid value action action specifier.
Definition utility.hpp:24
Validates that T is the same as one of the types defined by Types.
Definition concepts.hpp:51
Defies the action specifier types.
A visitor structure used to apply value actions.
Definition utility.hpp:50
value_type & value
A reference to the argument's value for which the action will be applied.
Definition utility.hpp:77
void operator()(const callable_type< action_type::observe, value_type > &action) const
The call operator overload for the observe action type.
Definition utility.hpp:57
void operator()(const callable_type< action_type::modify, value_type > &action) const
The call operator overload for the modify action type.
Definition utility.hpp:73
void operator()(const callable_type< action_type::transform, value_type > &action) const
The call operator overload for the transform action type.
Definition utility.hpp:65
typename AS::template type< T > callable_type
Template argument action callable type alias.
Definition utility.hpp:36
std::variant< callable_type< action_type::observe, T >, callable_type< action_type::transform, T >, callable_type< action_type::modify, T > > value_action_variant_type
Template argument action callabla variant type alias.
Definition utility.hpp:43