Helper functions, types, concepts, etc.
More...
|
| template<typename T > |
| auto | ap::util::any_range_cast_view (const c_range_of< std::any > auto &range) |
| | Casts a range of std::any to a range of type T.
|
| |
| template<c_writable T> |
| std::string | ap::util::as_string (const T &value) noexcept |
| | Converts a value to std::string.
|
| |
template<std::ranges::range R>
requires (c_writable<std::ranges::range_value_t<R>>) |
| std::string | ap::util::join (const R &range, const std::string_view delimiter=", ") |
| | Joins elements of a range into a single string with a delimiter.
|
| |
| template<typename T > |
| constexpr std::string_view | ap::util::get_demangled_type_name () |
| | Retrieves the demangled name of a type T.
|
| |
Helper functions, types, concepts, etc.
◆ callable_type
Template argument action callable type alias.
Definition at line 22 of file helpers.hpp.
◆ type_validator
Specifies the type validation rule.
| Enumerator |
|---|
| same | Exact type match.
|
| convertible | Implicit conversion allowed.
|
Definition at line 82 of file concepts.hpp.
◆ any_range_cast_view()
template<typename T >
| auto ap::util::any_range_cast_view |
( |
const c_range_of< std::any > auto & |
range | ) |
|
Casts a range of std::any to a range of type T.
- Template Parameters
-
- Parameters
-
| range | The input range of std::any. |
- Returns
- A view representing the casted range of type
T.
- Exceptions
-
| std::bad_any_cast | if any element in the input range cannot be cast to type T. |
Definition at line 28 of file ranges.hpp.
◆ as_string()
template<c_writable T>
| std::string ap::util::as_string |
( |
const T & |
value | ) |
|
|
noexcept |
Converts a value to std::string.
- Template Parameters
-
- Parameters
-
| value | The value to convert. |
Definition at line 27 of file string.hpp.
◆ get_demangled_type_name()
template<typename T >
| constexpr std::string_view ap::util::get_demangled_type_name |
( |
| ) |
|
|
constexpr |
Retrieves the demangled name of a type T.
- Template Parameters
-
| T | The type to retrieve the name for. |
- Returns
- A string view representing the demangled name of type
T.
- Note
- - The function uses compiler-specific macros to extract the type name.
-
- Supported compilers: GCC, Clang, MSVC.
Definition at line 29 of file typing.hpp.
◆ join()
template<std::ranges::range R>
requires (c_writable<std::ranges::range_value_t<R>>)
| std::string ap::util::join |
( |
const R & |
range, |
|
|
const std::string_view |
delimiter = ", " |
|
) |
| |
Joins elements of a range into a single string with a delimiter.
- Template Parameters
-
| R | The type of the value range. The value type of R must satisfy the c_writable concept. |
- Parameters
-
| range | The input range to join. |
| delimiter | The separator string to insert between elements. |
- Returns
- A single string with all elements joined by the delimiter.
- Todo:
- Replace with std::views::join after transition to C++23.
- Examples
- /home/runner/work/cpp-ap/cpp-ap/include/ap/argument_parser.hpp.
Definition at line 49 of file string.hpp.
◆ is_valid_type_v
| constexpr bool ap::util::is_valid_type_v = false |
|
inlineconstexpr |
Checks if two types satisfy a given type_validator rule.
The primary template of the is_valid_type_v helper variable, which does not perform any logic and defaults to false.
- Template Parameters
-
| T | The type to check. |
| U | The type to check agains. |
| TV | The validation rule. |
Definition at line 99 of file concepts.hpp.