52e8622199
* include/Makefile.am: Add any and c++17_warning.h to exported headers. * include/Makefile.in: Likewise. * include/std/any: New. * testsuite/20_util/any/assign/1.cc: Likewise. * testsuite/20_util/any/assign/2.cc: Likewise. * testsuite/20_util/any/assign/self.cc: Likewise. * testsuite/20_util/any/cons/1.cc: Likewise. * testsuite/20_util/any/cons/2.cc: Likewise. * testsuite/20_util/any/cons/aligned.cc: Likewise. * testsuite/20_util/any/cons/nontrivial.cc: Likewise. * testsuite/20_util/any/misc/any_cast.cc: Likewise. * testsuite/20_util/any/misc/any_cast_neg.cc: Likewise. * testsuite/20_util/any/misc/any_cast_no_rtti.cc: Likewise. * testsuite/20_util/any/misc/swap.cc: Likewise. * testsuite/20_util/any/modifiers/1.cc: Likewise. * testsuite/20_util/any/observers/type.cc: Likewise. * testsuite/20_util/any/typedefs.cc: Likewise. From-SVN: r238061
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
// { dg-options "-std=gnu++17" }
|
|
// { dg-do run }
|
|
|
|
// Copyright (C) 2014-2016 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
|
|
// terms of the GNU General Public License as published by the
|
|
// Free Software Foundation; either version 3, or (at your option)
|
|
// any later version.
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
// with this library; see the file COPYING3. If not see
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
#include <any>
|
|
#include <testsuite_hooks.h>
|
|
|
|
using std::any;
|
|
using std::any_cast;
|
|
|
|
struct X
|
|
{
|
|
bool moved = false;
|
|
bool moved_from = false;
|
|
X() = default;
|
|
X(const X&) = default;
|
|
X(X&& x) : moved(true) { x.moved_from = true; }
|
|
};
|
|
|
|
void test01()
|
|
{
|
|
X x;
|
|
any a1(x);
|
|
VERIFY(x.moved_from == false);
|
|
any a2(std::move(x));
|
|
VERIFY(x.moved_from == true);
|
|
VERIFY(any_cast<X&>(a2).moved == true );
|
|
}
|
|
|
|
int main()
|
|
{
|
|
test01();
|
|
}
|