[Bug libstdc++/78442] [variant] std::get<...>(Variant) is not constexpr.

eric at efcs dot ca gcc-bugzilla@gcc.gnu.org
Mon Nov 21 23:24:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78442

--- Comment #2 from Eric Fiselier <eric at efcs dot ca> ---
I'm sorry your right. That's a garbage reproducer. Here's an actual one:

#include <tuple>
#include <variant>

constexpr bool test_tuple() {
 std::tuple<int> t(42);
 return std::get<0>(t) == 42;
}
static_assert(test_tuple(), ""); // OK

constexpr bool test() {
  std::variant<int, void*> v(42);
  auto const& cv = v;
  return std::get<0>(v) == 42 &&
         std::get<0>(cv) == 42; 

}
static_assert(test(), "");


More information about the Gcc-bugs mailing list