Commit e8043fa6 by Jonathan Wakely Committed by Jonathan Wakely

status_cxx2014.xml: Update Fundamentals TS status.

	* doc/xml/manual/status_cxx2014.xml: Update Fundamentals TS status.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/experimental/any: New.
	* include/ext/aligned_buffer.h (__aligned_buffer(nullptr_t)): New
	constructor.
	* testsuite/experimental/any/assign/1.cc: New.
	* testsuite/experimental/any/assign/2.cc: New.
	* testsuite/experimental/any/cons/1.cc: New.
	* testsuite/experimental/any/cons/2.cc: New.
	* testsuite/experimental/any/cons/3.cc: New.
	* testsuite/experimental/any/misc/any_cast.cc: New.
	* testsuite/experimental/any/misc/any_cast_neg.cc: New.
	* testsuite/experimental/any/misc/any_cast_no_rtti.cc: New.
	* testsuite/experimental/any/misc/swap.cc: New.
	* testsuite/experimental/any/modifiers/1.cc: New.
	* testsuite/experimental/any/observers/type.cc: New.

From-SVN: r211669
parent ab938b41
2014-06-14 Jonathan Wakely <jwakely@redhat.com>
* doc/xml/manual/status_cxx2014.xml: Update Fundamentals TS status.
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/experimental/any: New.
* include/ext/aligned_buffer.h (__aligned_buffer(nullptr_t)): New
constructor.
* testsuite/experimental/any/assign/1.cc: New.
* testsuite/experimental/any/assign/2.cc: New.
* testsuite/experimental/any/cons/1.cc: New.
* testsuite/experimental/any/cons/2.cc: New.
* testsuite/experimental/any/cons/3.cc: New.
* testsuite/experimental/any/misc/any_cast.cc: New.
* testsuite/experimental/any/misc/any_cast_neg.cc: New.
* testsuite/experimental/any/misc/any_cast_no_rtti.cc: New.
* testsuite/experimental/any/misc/swap.cc: New.
* testsuite/experimental/any/modifiers/1.cc: New.
* testsuite/experimental/any/observers/type.cc: New.
2014-06-11 Maciej W. Rozycki <macro@codesourcery.com>
* testsuite/27_io/basic_ostream/inserters_arithmetic/wchar_t/4402.cc
......
......@@ -306,14 +306,13 @@ not in any particular release.
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3804.html">
N3804
</link>
</entry>
<entry>Any library proposal</entry>
<entry>N</entry>
<entry>Y</entry>
<entry>Library Fundamentals TS</entry>
</row>
......
......@@ -638,6 +638,7 @@ decimal_headers = \
experimental_srcdir = ${glibcxx_srcdir}/include/experimental
experimental_builddir = ./experimental
experimental_headers = \
${experimental_srcdir}/any \
${experimental_srcdir}/optional \
${experimental_srcdir}/string_view \
${experimental_srcdir}/string_view.tcc
......
......@@ -904,6 +904,7 @@ decimal_headers = \
experimental_srcdir = ${glibcxx_srcdir}/include/experimental
experimental_builddir = ./experimental
experimental_headers = \
${experimental_srcdir}/any \
${experimental_srcdir}/optional \
${experimental_srcdir}/string_view \
${experimental_srcdir}/string_view.tcc
......
......@@ -47,6 +47,11 @@ namespace __gnu_cxx
std::aligned_storage<sizeof(_Tp), std::alignment_of<_Tp>::value>::type
_M_storage;
__aligned_buffer() = default;
// Can be used to avoid value-initialization
__aligned_buffer(std::nullptr_t) { }
void*
_M_addr() noexcept
{
......
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2014 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 <experimental/any>
#include <testsuite_hooks.h>
using std::experimental::any;
void test01()
{
any x;
any y;
y = x;
VERIFY( x.empty() );
VERIFY( y.empty() );
y = std::move(x);
VERIFY( x.empty() );
VERIFY( y.empty() );
}
void test02()
{
any x(1);
any y;
y = x;
VERIFY( !x.empty() );
VERIFY( !y.empty() );
x = std::move(y);
VERIFY( !x.empty() );
VERIFY( y.empty() );
x = y;
VERIFY( x.empty() );
VERIFY( y.empty() );
}
int main()
{
test01();
test02();
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2014 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 <experimental/any>
#include <testsuite_hooks.h>
using std::experimental::any;
using std::experimental::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;
a1 = x;
VERIFY(x.moved_from == false);
any a2;
a2 = std::move(x);
VERIFY(x.moved_from == true);
VERIFY(any_cast<X&>(a2).moved == true );
}
int main()
{
test01();
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2014 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 <experimental/any>
#include <testsuite_hooks.h>
using std::experimental::any;
void test01()
{
any x;
VERIFY( x.empty() );
any y(x);
VERIFY( x.empty() );
VERIFY( y.empty() );
any z(std::move(y));
VERIFY( y.empty() );
VERIFY( z.empty() );
}
void test02()
{
any x(1);
VERIFY( !x.empty() );
any y(x);
VERIFY( !x.empty() );
VERIFY( !y.empty() );
any z(std::move(y));
VERIFY( y.empty() );
VERIFY( !z.empty() );
}
int main()
{
test01();
test02();
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2014 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 <experimental/any>
#include <testsuite_hooks.h>
using std::experimental::any;
using std::experimental::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();
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2014 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 <experimental/any>
#include <testsuite_allocator.h>
using std::experimental::any;
using __gnu_test::CustomPointerAlloc;
using __gnu_test::tracker_allocator;
using __gnu_test::tracker_allocator_counter;
struct NotSmall { char c[64]; };
bool test [[gnu::unused]] = true;
void test01()
{
CustomPointerAlloc<int> alloc;
any x(std::allocator_arg, alloc, 1);
VERIFY( !x.empty() );
any y(std::allocator_arg, alloc, std::move(x));
VERIFY( x.empty() );
VERIFY( !y.empty() );
}
void test02()
{
tracker_allocator<int> alloc;
any x(std::allocator_arg, alloc, 1);
auto allocated = tracker_allocator_counter::get_allocation_count();
VERIFY( allocated == 0 ); // no allocation for small object
any y(std::allocator_arg, alloc, std::move(x));
VERIFY( tracker_allocator_counter::get_allocation_count() == 0 );
y = {};
VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 );
}
void test03()
{
tracker_allocator<int> alloc;
any x(std::allocator_arg, alloc, NotSmall{});
auto allocated = tracker_allocator_counter::get_allocation_count();
__builtin_printf("ALLOCATED %lu\n", (unsigned long)allocated);
VERIFY( allocated >= sizeof(NotSmall) );
any y(std::allocator_arg, alloc, std::move(x));
VERIFY( tracker_allocator_counter::get_allocation_count() == allocated );
y = {};
VERIFY( tracker_allocator_counter::get_deallocation_count() == allocated );
}
int main()
{
test01();
test02();
test03();
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2014 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 <experimental/any>
#include <string>
#include <cstring>
#include <testsuite_hooks.h>
using std::experimental::any;
using std::experimental::any_cast;
void test01()
{
using std::string;
using std::strcmp;
// taken from example in N3804 proposal
any x(5); // x holds int
VERIFY(any_cast<int>(x) == 5); // cast to value
any_cast<int&>(x) = 10; // cast to reference
VERIFY(any_cast<int>(x) == 10);
x = "Meow"; // x holds const char*
VERIFY(strcmp(any_cast<const char*>(x), "Meow") == 0);
any_cast<const char*&>(x) = "Harry";
VERIFY(strcmp(any_cast<const char*>(x), "Harry") == 0);
x = string("Meow"); // x holds string
string s, s2("Jane");
s = move(any_cast<string&>(x)); // move from any
VERIFY(s == "Meow");
any_cast<string&>(x) = move(s2); // move to any
VERIFY(any_cast<const string&>(x) == "Jane");
string cat("Meow");
const any y(cat); // const y holds string
VERIFY(any_cast<const string&>(y) == cat);
}
void test02()
{
using std::experimental::bad_any_cast;
any x(1);
auto p = any_cast<double>(&x);
VERIFY(p == nullptr);
x = 1.0;
p = any_cast<double>(&x);
VERIFY(p != nullptr);
x = any();
p = any_cast<double>(&x);
VERIFY(p == nullptr);
try {
any_cast<double>(x);
VERIFY(false);
} catch (const bad_any_cast&) {
}
}
void test03()
{
using std::experimental::bad_any_cast;
any x(std::allocator_arg, std::allocator<double>{}, 1);
auto p = any_cast<double>(&x);
VERIFY(p == nullptr);
x = any(std::allocator_arg, std::allocator<int>{}, 1.0);
p = any_cast<double>(&x);
VERIFY(p != nullptr);
x = any(std::allocator_arg, std::allocator<char>{});
p = any_cast<double>(&x);
VERIFY(p == nullptr);
try {
any_cast<double>(x);
VERIFY(false);
} catch (const bad_any_cast&) {
}
}
int main()
{
test01();
test02();
test03();
}
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2014 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 <experimental/any>
void test01()
{
using std::experimental::any;
using std::experimental::any_cast;
const any y(1);
any_cast<int&>(y); // { dg-error "qualifiers" "" { target { *-*-* } } 381 }
}
// { dg-options "-std=gnu++14 -fno-rtti" }
// { dg-do run }
// Copyright (C) 2014 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 <experimental/any>
#include <string>
#include <cstring>
#include <testsuite_hooks.h>
using std::experimental::any;
using std::experimental::any_cast;
void test01()
{
using std::experimental::bad_any_cast;
any x(1);
auto p = any_cast<double>(&x);
VERIFY(p == nullptr);
x = 1.0;
p = any_cast<double>(&x);
VERIFY(p != nullptr);
x = any();
p = any_cast<double>(&x);
VERIFY(p == nullptr);
try {
any_cast<double>(x);
VERIFY(false);
} catch (const bad_any_cast&) {
}
}
int main()
{
test01();
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2014 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 <experimental/any>
#include <testsuite_hooks.h>
using std::experimental::any;
void test01()
{
any x(1);
any y;
swap(x, y);
VERIFY( x.empty() );
VERIFY( !y.empty() );
}
int main()
{
test01();
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2014 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 <experimental/any>
#include <testsuite_hooks.h>
using std::experimental::any;
void test01()
{
any x(1);
any y;
x.swap(y);
VERIFY( x.empty() );
VERIFY( !y.empty() );
x.swap(y);
VERIFY( !x.empty() );
VERIFY( y.empty() );
x.clear();
VERIFY( x.empty() );
}
int main()
{
test01();
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2014 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 <experimental/any>
#include <testsuite_hooks.h>
using std::experimental::any;
void test01()
{
any x;
VERIFY( x.type() == typeid(void) );
x = 1;
VERIFY( x.type() == typeid(int) );
x = any();
VERIFY( x.type() == typeid(void) );
}
int main()
{
test01();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment