Construction from a single character added to a fixed_string

This commit is contained in:
Mateusz Pusz
2019-11-04 06:30:22 +00:00
parent 5f216af4de
commit 7e844ef773

View File

@@ -31,6 +31,11 @@ namespace units {
struct basic_fixed_string { struct basic_fixed_string {
CharT data_[N + 1] = {}; CharT data_[N + 1] = {};
constexpr basic_fixed_string(CharT ch) noexcept
{
data_[0] = ch;
}
constexpr basic_fixed_string(const CharT (&txt)[N + 1]) noexcept constexpr basic_fixed_string(const CharT (&txt)[N + 1]) noexcept
{ {
for(std::size_t i = 0; i < N; ++i) for(std::size_t i = 0; i < N; ++i)
@@ -97,6 +102,9 @@ namespace units {
template<typename CharT, std::size_t N> template<typename CharT, std::size_t N>
basic_fixed_string(const CharT (&str)[N]) -> basic_fixed_string<CharT, N-1>; basic_fixed_string(const CharT (&str)[N]) -> basic_fixed_string<CharT, N-1>;
template<typename CharT>
basic_fixed_string(CharT) -> basic_fixed_string<CharT, 1>;
template<std::size_t N> template<std::size_t N>
using fixed_string = basic_fixed_string<char, N>; using fixed_string = basic_fixed_string<char, N>;