feat: basic_fixed_string contructor now can take a list of arguments

This commit is contained in:
Mateusz Pusz
2024-01-18 18:59:10 +01:00
parent 5183a5c830
commit 40dcc9de66

View File

@@ -57,18 +57,18 @@ struct basic_fixed_string {
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
constexpr explicit basic_fixed_string(CharT ch) noexcept
requires(N == 1)
{
data_[0] = ch;
}
constexpr explicit(false) basic_fixed_string(const CharT (&txt)[N + 1]) noexcept
{
if constexpr (N != 0)
for (std::size_t i = 0; i < N; ++i) data_[i] = txt[i];
}
template<std::convertible_to<CharT>... Rest>
requires(1 + sizeof...(Rest) == N)
constexpr explicit basic_fixed_string(CharT first, Rest... rest) noexcept : data_{first, rest..., CharT('\0')}
{
}
constexpr basic_fixed_string(const CharT* ptr, std::integral_constant<std::size_t, N>) noexcept
{
if constexpr (N != 0)
@@ -131,12 +131,12 @@ struct basic_fixed_string {
}
};
template<typename CharT>
basic_fixed_string(CharT) -> basic_fixed_string<CharT, 1>;
template<typename CharT, std::size_t N>
basic_fixed_string(const CharT (&str)[N]) -> basic_fixed_string<CharT, N - 1>;
template<typename CharT, std::convertible_to<CharT>... Rest>
basic_fixed_string(CharT, Rest...) -> basic_fixed_string<CharT, 1 + sizeof...(Rest)>;
template<typename CharT, std::size_t N>
basic_fixed_string(const CharT* ptr, std::integral_constant<std::size_t, N>) -> basic_fixed_string<CharT, N>;