Why are my two tuples containing strings, created the same way, not equal?

You are comparing pointers to buffers of characters, not strings.

Sometimes the compiler will turn two different "one"s into the same buffer, sometimes it will not.

In your case, it isn’t. Probably a debug build.

Add #include <string_view>, then

using namespace std::literals;

auto t1 = std::make_tuple("one"sv, "two"sv, "three"sv);
auto t2 = std::make_tuple("one"sv, "two"sv, "three"sv);

and you’ll get what you expect. (In pre-c++17 compilers, use <string> and ""s instead of <string_view> and ""sv).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)