| 1 |
// // PR c++/65202 |
| 2 |
// { dg-do compile { target c++14 } } |
| 3 |
// { dg-additional-options "-Wno-return-type" } |
| 4 |
|
| 5 |
template <typename T> struct is_move_constructible; |
| 6 |
template <typename T> struct is_move_assignable; |
| 7 |
template <int, typename T> using enable_if_t = int; |
| 8 |
namespace adl { |
| 9 |
template < |
| 10 |
typename L, typename R, |
| 11 |
enable_if_t<is_move_constructible<L>() && is_move_assignable<L>(), int>...> |
| 12 |
constexpr auto adl_swap(L &l, R &r) -> decltype(swap(l, r)) { |
| 13 |
return; |
| 14 |
} |
| 15 |
template <typename L, typename R> |
| 16 |
auto swap(L &l, R &r) noexcept(noexcept(adl::adl_swap(l, r))) |
| 17 |
-> decltype(adl::adl_swap(l, r)); |
| 18 |
namespace ns { |
| 19 |
template <typename T> struct foo {}; |
| 20 |
template <typename T> void swap(foo<T> &, foo<T> &); |
| 21 |
struct bar; |
| 22 |
|
| 23 |
int main() |
| 24 |
{ |
| 25 |
foo<ns::bar> f; |
| 26 |
adl::swap(f, f) // { dg-error "expected ';'" } |
| 27 |
} // { dg-error "2:expected" } |