tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
basic_format_string.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2023 Tobias Hienzsch
3
4#ifndef TETL_FORMAT_BASIC_FORMAT_STRING_HPP
5#define TETL_FORMAT_BASIC_FORMAT_STRING_HPP
6
7#include <etl/_concepts/convertible_to.hpp>
8#include <etl/_string_view/basic_string_view.hpp>
9#include <etl/_type_traits/type_identity.hpp>
10
11namespace etl {
12
13template <typename CharT, typename... Args>
15 template <typename T>
16 requires convertible_to<T const&, basic_string_view<CharT>>
17 consteval basic_format_string(T const& s)
18 : _str(s)
19 {
20 }
21
22 [[nodiscard]] constexpr auto get() const noexcept -> basic_string_view<CharT>
23 {
24 return _str;
25 }
26
27private:
28 basic_string_view<CharT> _str;
29};
30
31template <typename... Args>
32using format_string = basic_format_string<char, type_identity_t<Args>...>;
33
34template <typename... Args>
35using wformat_string = basic_format_string<wchar_t, type_identity_t<Args>...>;
36
37} // namespace etl
38
39#endif // TETL_FORMAT_BASIC_FORMAT_STRING_HPP
Definition adjacent_find.hpp:9
Definition basic_format_string.hpp:14
constexpr auto get() const noexcept -> basic_string_view< CharT >
Definition basic_format_string.hpp:22
consteval basic_format_string(T const &s)
Definition basic_format_string.hpp:17
The class template basic_string_view describes an object that can refer to a constant contiguous sequ...
Definition basic_string_view.hpp:35