25#ifndef JAU_STRING_LITERAL_HPP_
26#define JAU_STRING_LITERAL_HPP_
54 template<
typename CharT, std::
size_t N>
73 template<std::convertible_to<CharT>... Chars>
74 requires(
sizeof...(Chars) == N) && (... && !std::is_pointer_v<Chars>)
76 : buf {chars..., CharT{}}
81 std::copy(str, str+N+1, buf);
84 template<std::
size_t S, std::
size_t T>
88 std::copy(s1.cbegin(), s1.cend(), buf);
89 std::copy(s2.cbegin(), s2.cend(), buf+S);
109 return std::equal(o.cbegin(), o.cend(), buf);
111 template<std::
size_t N2>
116 return n < N ? buf[n] : CharT{};
119 template<std::
size_t N2>
134 constexpr bool empty() const noexcept {
return 0==N; };
136 constexpr const char*
c_str() const noexcept {
return buf; }
139 constexpr std::basic_string_view<CharT>
view() const noexcept {
140 return std::basic_string_view<CharT>(
cbegin(),
cend());
142 constexpr operator std::basic_string_view<CharT>() const noexcept {
return view(); }
146 template<
typename CharT, std::convertible_to<CharT>... Rest>
150 template<
typename CharT,
size_t O>
157 template<
typename CharT, std::
size_t N, std::
size_t O>
162 template<
typename CharT,
size_t O, std::
size_t N>
Static compile-time string literal storage.
constexpr BasicStringLiteral(BasicStringLiteral &&o) noexcept=default
ptrdiff_t difference_type
constexpr size_type size() const noexcept
string literal size w/o EOS.
constexpr const_reverse_iterator rbegin() const noexcept
constexpr BasicStringLiteral(const CharT(&str)[N+1]) noexcept
Implicit constructor from string literal const CharT (&str)[N+1], i.e. including EOS.
constexpr const_iterator end() const noexcept
constexpr const_iterator begin() const noexcept
constexpr size_type length() const noexcept
string literal size w/o EOS.
constexpr BasicStringLiteral(const BasicStringLiteral< CharT, S > &s1, const BasicStringLiteral< CharT, T > &s2) noexcept
constexpr const char * c_str() const noexcept
Returns c-string w/ EOS.
constexpr const_iterator cend() const noexcept
constexpr BasicStringLiteral(Chars... chars) noexcept
constexpr BasicStringLiteral & operator=(BasicStringLiteral &&o) noexcept=default
std::reverse_iterator< const_iterator > const_reverse_iterator
constexpr const_reverse_iterator rend() const noexcept
constexpr bool empty() const noexcept
constexpr BasicStringLiteral & operator=(const BasicStringLiteral &o) noexcept=default
constexpr BasicStringLiteral< CharT, N+N2 > operator+(const BasicStringLiteral< CharT, N2 > &o) const
constexpr size_type max_size() const noexcept
string literal size w/o EOS.
const CharT & const_reference
constexpr const_pointer data() const noexcept
Returns c-string w/ EOS.
constexpr BasicStringLiteral(const BasicStringLiteral &o) noexcept=default
const CharT * const_pointer
constexpr CharT operator[](std::size_t n) const noexcept
constexpr const_reverse_iterator crbegin() const noexcept
const CharT * const_iterator
constexpr const_iterator cbegin() const noexcept
constexpr bool operator==(const BasicStringLiteral &o) const noexcept
constexpr bool operator==(const BasicStringLiteral< CharT, N2 >) const noexcept
constexpr const_reverse_iterator crend() const noexcept
constexpr std::basic_string_view< CharT > view() const noexcept
constexpr fraction< int_type > operator+(const fraction< int_type > &lhs, const fraction< int_type > &rhs) noexcept
Returns sum of two fraction.
BasicStringLiteral(CharT, Rest...) -> BasicStringLiteral< CharT, 1+sizeof...(Rest)>
BasicStringLiteral< char, N > StringLiteral
BasicStringLiteral< wchar_t, N > WStringLiteral
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.