Skip to content

Commit

Permalink
No more string literal operator template for now :(
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinchowdhury18 committed Nov 7, 2023
1 parent 68362e1 commit 9c8c004
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@ constexpr bool operator!= (const std::string_view& lhs, const StringLiteral<N>&
#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
namespace string_literals
{
template <StringLiteral sl>
constexpr auto operator"" _sl()
{
return sl;
}
// MSVC doesn't support this yet :(
// template <StringLiteral sl>
// constexpr auto operator"" _sl()
// {
// return sl;
// }

template <char... str>
constexpr auto operator"" _sl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TEST_CASE ("String Literal Test", "[common][data-structures]")
{
SECTION ("Construction")
{
static constexpr auto sl1 = "TEST"_sl;
static constexpr auto sl1 = chowdsp::StringLiteral { "TEST" };
STATIC_REQUIRE (sl1.data()[0] == 'T');
STATIC_REQUIRE (std::is_same_v<std::remove_cv_t<decltype (sl1)>, chowdsp::StringLiteral<5>>);

Expand Down Expand Up @@ -82,6 +82,6 @@ TEST_CASE ("String Literal Test", "[common][data-structures]")
SECTION ("Numbers")
{
static constexpr auto fifteen = 15_sl;
REQUIRE (fifteen == "15"_sl);
REQUIRE (fifteen == chowdsp::StringLiteral { "15" });
}
}

0 comments on commit 9c8c004

Please sign in to comment.