#pragma once #include #include namespace saw { /** * Helper object which creates a templated string from the provided string * literal. It guarantees compile time uniqueness and thus allows using strings * in template parameters. */ template class StringLiteral { public: constexpr StringLiteral(const CharT (&input)[N]) noexcept { for (size_t i = 0; i < N; ++i) { data[i] = input[i]; } } std::array data{}; constexpr std::string_view view() const noexcept { return std::string_view{data.data()}; } constexpr bool operator==(const StringLiteral &) const noexcept = default; template constexpr bool operator==(const StringLiteral &) const noexcept { return false; } }; template constexpr StringLiteral operator""_key() { return StringLiteral{Chars..., '\0'}; } } // namespace saw