1#ifndef LIBSBX_UTILITY_STRING_LITERAL_HPP_
2#define LIBSBX_UTILITY_STRING_LITERAL_HPP_
11namespace sbx::utility {
15template<std::forward_iterator InputIterator, std::sentinel_for<InputIterator> Sentinel, std::forward_iterator OutputIterator>
16constexpr auto copy(InputIterator first, Sentinel last, OutputIterator result) -> OutputIterator {
17 while (first != last) {
26template<
typename Character, std::
size_t Size>
31 using character_type = Character;
32 using size_type = std::size_t;
33 using iterator =
const character_type*;
34 using string_view_type = std::basic_string_view<character_type>;
36 static constexpr auto npos = std::numeric_limits<size_type>::max();
39 detail::copy(data, data + Size - 1, _data.data());
42 constexpr auto begin()
const noexcept -> iterator {
43 return std::begin(_data);
46 constexpr auto end()
const noexcept -> iterator {
47 return std::end(_data.data());
50 constexpr auto data()
const noexcept ->
const character_type* {
54 constexpr auto size()
const noexcept -> size_type {
58 constexpr auto is_empty()
const noexcept ->
bool {
62 constexpr auto operator[](size_type index)
const noexcept -> character_type {
66 constexpr operator string_view_type()
const noexcept {
67 return string_view_type{_data.data(), Size};
70 std::array<character_type, Size - 1> _data;
74template<std::
size_t Size>
77template<std::
size_t Size>
82template<std::
size_t Size>
83struct fmt::formatter<sbx::utility::string_literal<Size>> {
85 template<
typename ParseContext>
86 constexpr auto parse(ParseContext& context) ->
decltype(context.begin()) {
87 return context.begin();
90 template<
typename FormatContext>
92 return fmt::format_to(context.out(),
"{}", fmt::join(value._data,
""));
Definition: string_literal.hpp:27