conststr 0.2.1
|
Main header file for the constant string type. More...
#include <algorithm>
#include <concepts>
#include <cstddef>
#include <iostream>
#include <iterator>
#include <string_view>
#include <tuple>
#include <type_traits>
Go to the source code of this file.
Classes | |
struct | conststr::sv_selector< T > |
String view type selector. Just an empty struct. More... | |
struct | conststr::cstr< N, T, view > |
String type that can be evaluated in a constant context. More... | |
struct | std::tuple_size< conststr::cstr< N, T, U > > |
Specialize std::tuple_size make cstr tuple-like. More... | |
struct | std::tuple_element< Idx, conststr::cstr< N, T, U > > |
Specialize std::tuple_element make cstr tuple-like. More... | |
struct | std::hash< conststr::cstr< N, T, U > > |
Specialize std::hash for cstr , depend on the view type of cstr . More... | |
Namespaces | |
namespace | conststr |
The outermost namespace of this library to avoid identifier pollution. | |
namespace | conststr::meta |
Some useful template meta. | |
namespace | conststr::charutils |
Some constexpr character operating functions. | |
namespace | conststr::literal |
Define string literal suffix. | |
Concepts | |
concept | conststr::meta::all_same |
This concept is satisfied if all types of Ts... the same type. | |
concept | conststr::meta::all_same_of |
This concept is satisfied if all values of Vs... has the same type. | |
concept | conststr::meta::hashable |
This concept is satisfied if std::hash<T> has specialization. | |
concept | conststr::meta::viewer |
This concept is satisfied if T is a view type to a constant contiguous sequence of Elem . | |
concept | conststr::charutils::char_like |
This concept is satisfied if T is a char-like type. | |
concept | conststr::can_construct_cstr_from |
This concept is satisfied if cstr can be constructed from T . | |
concept | conststr::can_construct_cstr_t_from |
This concept is satisfied if cstr can be constructed from T and the value_type of the cstr is CharT . | |
concept | conststr::can_construct_cstr_t_n_from |
This concept is satisfied if cstr can be constructed from T and the value_type of the cstr is CharT and length is Len . | |
Typedefs | |
template<typename... Ts> | |
using | conststr::meta::first_t = std::tuple_element_t< 0, std::tuple< Ts... > > |
Get the first type of class template parameter pack. More... | |
template<auto... Vs> | |
using | conststr::meta::first_t_of = std::remove_cvref_t< std::tuple_element_t< 0, decltype(std::tuple{Vs...})> > |
Get the type of the first value of variable template parameter pack. More... | |
template<typename... Ts> | |
using | conststr::meta::last_t = std::tuple_element_t< sizeof...(Ts) - 1, std::tuple< Ts... > > |
Get the last type of class template parameter pack. More... | |
template<auto... Vs> | |
using | conststr::meta::last_t_of = std::remove_cvref_t< std::tuple_element_t< sizeof...(Vs) - 1, decltype(std::tuple{Vs...})> > |
Get the type of the last value of variable template parameter pack. More... | |
Functions | |
template<char_like T> | |
constexpr bool | conststr::charutils::islower (T ch) |
constexpr re-implementation of std::islower . | |
template<char_like T> | |
constexpr bool | conststr::charutils::issuper (T ch) |
constexpr re-implementation of std::issuper . | |
template<char_like T> | |
constexpr bool | conststr::charutils::isdigit (T ch) |
constexpr re-implementation of std::isdigit . | |
template<char_like T> | |
constexpr bool | conststr::charutils::isalpha (T ch) |
constexpr re-implementation of std::isalpha . | |
template<char_like T> | |
constexpr bool | conststr::charutils::isalnum (T ch) |
constexpr re-implementation of std::isalnum . | |
template<char_like T> | |
constexpr bool | conststr::charutils::isxdigit (T ch) |
constexpr re-implementation of std::isxdigit . | |
template<char_like T> | |
constexpr bool | conststr::charutils::iscntrl (T ch) |
constexpr re-implementation of std::iscntrl . | |
template<char_like T> | |
constexpr bool | conststr::charutils::ispunct (T ch) |
constexpr re-implementation of std::ispunct . | |
template<char_like T> | |
constexpr bool | conststr::charutils::isblank (T ch) |
constexpr re-implementation of std::isblank . | |
template<char_like T> | |
constexpr bool | conststr::charutils::isspace (T ch) |
constexpr re-implementation of std::isspace . | |
template<char_like T> | |
constexpr bool | conststr::charutils::isgraph (T ch) |
constexpr re-implementation of std::isgraph . | |
template<char_like T> | |
constexpr bool | conststr::charutils::isprint (T ch) |
constexpr re-implementation of std::isprint . | |
template<char_like T> | |
constexpr char | conststr::charutils::toupper (T ch) |
constexpr re-implementation of std::toupper . | |
template<char_like T> | |
constexpr char | conststr::charutils::tolower (T ch) |
constexpr re-implementation of std::tolower . | |
template<char_like T> | |
constexpr char | conststr::charutils::invert (T ch) |
Invert case of letter. | |
template<char_like auto... Chs> requires meta::all_same_of<Chs...> && (sizeof...(Chs) > 1) | |
constexpr bool | conststr::charutils::is (meta::first_t_of< Chs... > ch) |
Check if input character the same as one of variable template parameters. More... | |
template<char_like auto Ch> | |
constexpr decltype(Ch) | conststr::charutils::just (decltype(Ch) ignored) |
No matter what the input is, always output Ch . More... | |
template<char_like auto... Chs> requires meta::all_same_of<Chs...> && (sizeof...(Chs) > 1) | |
constexpr meta::last_t_of< Chs... > | conststr::charutils::replace (meta::last_t_of< Chs... > ch) |
Replace the input character if it is the same as one of variable template parameters. More... | |
template<char_like auto... Chs> requires meta::all_same_of<Chs...> && (sizeof...(Chs) > 1) | |
constexpr meta::last_t_of< Chs... > | conststr::charutils::remain (meta::last_t_of< Chs... > ch) |
Replace the input character if it is NOT one of variable template parameters. More... | |
template<charutils::char_like T, std::size_t N> | |
conststr::cstr (const T(&)[N]) -> cstr< N - 1, T, std::basic_string_view< T > > | |
Deduction guide for cstr with default view type. | |
template<charutils::char_like T, std::size_t N, meta::viewer< T > V> | |
conststr::cstr (const T(&)[N], const sv_selector< V > &) -> cstr< N - 1, T, V > | |
Deduction guide for cstr with string view type selector. | |
template<charutils::char_like T> | |
conststr::cstr (const T &ch) -> cstr< 1, T, std::basic_string_view< T > > | |
Deduction guide for cstr with default view type. | |
template<charutils::char_like T, meta::viewer< T > V> | |
conststr::cstr (const T &ch, const sv_selector< V > &) -> cstr< 1, T, V > | |
Deduction guide for cstr with string view type selector. | |
template<std::size_t Idx, charutils::char_like T, typename U , std::size_t N> | |
cstr< N, T, U >::reference | conststr::get (cstr< N, T, U > &str) noexcept |
Tuple-like interface, extracts the Idx-th element from the string. More... | |
template<std::size_t Idx, charutils::char_like T, typename U , std::size_t N> | |
cstr< N, T, U >::const_reference | conststr::get (const cstr< N, T, U > &str) noexcept |
Tuple-like interface, extracts the Idx-th element from the string. More... | |
template<std::size_t Idx, charutils::char_like T, typename U , std::size_t N> | |
cstr< N, T, U >::rreference | conststr::get (cstr< N, T, U > &&str) noexcept |
Tuple-like interface, extracts the Idx-th element from the string. More... | |
template<std::size_t Idx, charutils::char_like T, typename U , std::size_t N> | |
const cstr< N, T, U >::const_rreference | conststr::get (const cstr< N, T, U > &&str) noexcept |
Tuple-like interface, extracts the Idx-th element from the string. More... | |
template<charutils::char_like T, typename V1 , typename V2 , std::size_t N> | |
constexpr void | conststr::swap (cstr< N, T, V1 > &lhs, cstr< N, T, V2 > &rhs) |
Satisfy the named requirement Swappable . More... | |
template<can_construct_cstr_from First, can_construct_cstr_from... Str> requires meta::all_same< typename decltype(cstr(std::declval<First>()))::value_type, typename decltype(cstr(std::declval<Str>()))::value_type...> | |
constexpr auto | conststr::flatten (const First &first, const Str &...strs) |
Flatten multiple strings of different lengths. More... | |
template<charutils::char_like T, typename U , std::size_t N> | |
std::ostream & | conststr::operator<< (std::ostream &os, const cstr< N, T, U > &str) |
Output string to std::ostream. | |
consteval auto | conststr::literal::operator""_cs (char ch) |
User-defined string literal with suffix _cs . More... | |
consteval auto | conststr::literal::operator""_cs (char8_t ch) |
User-defined string literal with suffix _cs . More... | |
consteval auto | conststr::literal::operator""_cs (char16_t ch) |
User-defined string literal with suffix _cs . More... | |
consteval auto | conststr::literal::operator""_cs (char32_t ch) |
User-defined string literal with suffix _cs . More... | |
consteval auto | conststr::literal::operator""_cs (wchar_t ch) |
User-defined string literal with suffix _cs . More... | |
template<cstr str> | |
consteval auto | conststr::literal::operator""_cs () |
User-defined string literal with suffix _cs . More... | |
Variables | |
template<auto... Vs> | |
constexpr auto | conststr::meta::first_v = [](auto first, auto...) { return first; }(Vs...) |
Get the first value of variable template parameter pack. More... | |
template<auto... Vs> | |
constexpr auto | conststr::meta::last_v = (Vs, ...) |
Get the last value of variable template parameter pack. More... | |
template<char_like To> | |
constexpr auto | conststr::charutils::cast |
Cast input character to the value of another character type. More... | |
template<typename T > | |
constexpr auto | conststr::sv = sv_selector<T>{} |
String view type selector. Assist in type deduction of cstr . More... | |
Main header file for the constant string type.