This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/60943] [C++14] Return type deduction interferes with ref-qualifiers


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

--- Comment #6 from Anders SjÃgren <anders at sjogren dot info> ---
An alternative test case, which also tests that the correct version is
selected, could be:

#include <type_traits>

using expected_lvalue_res_t = int;
using expected_rvalue_res_t = double;

struct A {
  auto f() & {return expected_lvalue_res_t{};}
  auto f() && {return expected_rvalue_res_t{};}
};

void lvalue_assert()
{
  A a;
  a.f();
  static_assert(std::is_same<decltype(a.f()),
expected_lvalue_res_t>::value,"");
}

void rvalue_assert()
{
  A{}.f();
  static_assert(std::is_same<decltype(A{}.f()),
expected_rvalue_res_t>::value,"");
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]