#ifndef RFL_INTERNAL_STRINGLITERAL_HPP_ #define RFL_INTERNAL_STRINGLITERAL_HPP_ #include #include #include #include namespace rfl { namespace internal { /// Normal strings cannot be used as template /// parameters, but this can. This is needed /// for the parameters names in the NamedTuples. template struct StringLiteral { constexpr StringLiteral(const auto... _chars) : arr_ {_chars..., '\0'} {} constexpr StringLiteral(const std::array _arr) : arr_(_arr) {} constexpr StringLiteral(const char (&_str)[N]) { std::copy_n(_str, N, std::data(arr_)); } /// Returns the value as a string. std::string str() const { return std::string(std::data(arr_), N - 1); } /// Returns the value as a string. constexpr std::string_view string_view() const { return std::string_view(std::data(arr_), N - 1); } std::array arr_ {}; }; template constexpr inline bool operator==(const StringLiteral& _first, const StringLiteral& _second) { if constexpr (N1 != N2) { return false; } return _first.string_view() == _second.string_view(); } template constexpr inline bool operator!=(const StringLiteral& _first, const StringLiteral& _second) { return !(_first == _second); } } // namespace internal } // namespace rfl #endif