// { dg-options "-std=gnu++17" }
// { dg-do compile }
-// Copyright (C) 2014-2016 Free Software Foundation, Inc.
+// Copyright (C) 2014-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
#include <any>
+using std::any;
+using std::any_cast;
+
void test01()
{
- using std::any;
- using std::any_cast;
-
const any y(1);
- any_cast<int&>(y); // { dg-error "invalid static_cast" "" { target { *-*-* } } 455 }
+ any_cast<int&>(y); // { dg-error "invalid 'static_cast'" "" { target { *-*-* } } 461 }
+ // { dg-error "Template argument must be constructible from a const value" "" { target { *-*-* } } 457 }
+}
+
+void test02()
+{
+ any y(1);
+ any_cast<int&&>(y);
+ // { dg-error "Template argument must be constructible from an lvalue" "" { target { *-*-* } } 483 }
+}
+
+void test03()
+{
+ any y(1);
+ any_cast<int&>(std::move(y)); // { dg-error "invalid 'static_cast'" "" { target { *-*-* } } 501 }
+ // { dg-error "Template argument must be constructible from an rvalue" "" { target { *-*-* } } 497 }
}