mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
Construction from a single character added to a fixed_string
This commit is contained in:
@@ -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>;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user