Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

C++: Why am I getting a static-assertion failure for this simple program?

I'm trying to experiment with std::tuple_cat but for some reason in my program the types do not match. Any idea why?

#include <tuple>

#include <type_traits>

int main()

{

    int x{0}, y{0};

    auto var = std::tuple_cat(std::tie(x), std::tie(y));

    static_assert(

        std::is_same<decltype(var), std::tuple<int, int>>::value, ""

    );

}

1 Answer

Relevance
  • ?
    Lv 7
    8 years ago
    Favorite Answer

    std::tie(x) doesn't create a std::tuple<int>, it creates std::tuple<int&>

Still have questions? Get your answers by asking now.