mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-07 06:04:27 +02:00
feat: basic_fixed_string(const CharT*, std::integral_constant<std::size_t, N>)
constructor added
This commit is contained in:
@@ -60,6 +60,12 @@ struct basic_fixed_string {
|
||||
for (std::size_t i = 0; i < N; ++i) data_[i] = txt[i];
|
||||
}
|
||||
|
||||
constexpr basic_fixed_string(const CharT* ptr, std::integral_constant<std::size_t, N>) noexcept
|
||||
{
|
||||
if constexpr (N != 0)
|
||||
for (std::size_t i = 0; i < N; ++i) data_[i] = *ptr++;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool empty() const noexcept { return N == 0; }
|
||||
[[nodiscard]] constexpr std::size_t size() const noexcept { return N; }
|
||||
[[nodiscard]] constexpr const CharT* data() const noexcept { return data_; }
|
||||
@@ -105,6 +111,9 @@ struct basic_fixed_string {
|
||||
template<typename CharT, std::size_t N>
|
||||
basic_fixed_string(const CharT (&str)[N]) -> basic_fixed_string<CharT, N - 1>;
|
||||
|
||||
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>;
|
||||
|
||||
template<typename CharT>
|
||||
basic_fixed_string(CharT) -> basic_fixed_string<CharT, 1>;
|
||||
|
||||
|
Reference in New Issue
Block a user