Commit 677aad9c by Jonathan Wakely Committed by Jonathan Wakely

Makefile.am: Add new header.

2011-07-09  Jonathan Wakely  <jwakely.gcc@gmail.com>

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/std/scoped_allocator: New.
	* doc/xml/manual/status_cxx200x.xml: Update.
	* testsuite/20_util/scoped_allocator/1.cc: New.
	* testsuite/20_util/scoped_allocator/propagation.cc: New.
	* testsuite/20_util/scoped_allocator/requirements/typedefs.cc: New.
	* testsuite/20_util/scoped_allocator/requirements/
	explicit_instantiation.cc: New.

From-SVN: r176079
parent bd8485dc
2011-07-09 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/std/scoped_allocator: New.
* doc/xml/manual/status_cxx200x.xml: Update.
* testsuite/20_util/scoped_allocator/1.cc: New.
* testsuite/20_util/scoped_allocator/propagation.cc: New.
* testsuite/20_util/scoped_allocator/requirements/typedefs.cc: New.
* testsuite/20_util/scoped_allocator/requirements/
explicit_instantiation.cc: New.
2011-07-09 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/stl_vector.h: Use new allocator model in C++0x mode.
* include/bits/vector.tcc: Likewise.
* testsuite/util/testsuite_allocator.h (propagating_allocator): Define.
......
......@@ -1009,52 +1009,47 @@ particular release.
<entry/>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>20.12</entry>
<entry>Scoped allocator adaptor</entry>
<entry/>
<entry>Partial</entry>
<entry/>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>20.12.1</entry>
<entry>Header <code>&lt;scoped_allocator&gt;</code> synopsis</entry>
<entry/>
<entry/>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>20.12.2</entry>
<entry>Scoped allocator adaptor member types</entry>
<entry>N</entry>
<entry>Y</entry>
<entry/>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>20.12.3</entry>
<entry>Scoped allocator adaptor constructors</entry>
<entry>N</entry>
<entry>Y</entry>
<entry/>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>20.12.4</entry>
<entry>Scoped allocator adaptor members</entry>
<entry>N</entry>
<entry>Partial</entry>
<entry/>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>20.12.5</entry>
<entry>Scoped allocator operators</entry>
<entry>N</entry>
<entry>Y</entry>
<entry/>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>20.13</entry>
<entry>Class <code>type_index</code></entry>
<entry>N</entry>
<entry>Y</entry>
<entry/>
</row>
<row>
......
......@@ -58,6 +58,7 @@ std_headers = \
${std_srcdir}/random \
${std_srcdir}/ratio \
${std_srcdir}/regex \
${std_srcdir}/scoped_allocator \
${std_srcdir}/set \
${std_srcdir}/sstream \
${std_srcdir}/stack \
......
......@@ -310,6 +310,7 @@ std_headers = \
${std_srcdir}/random \
${std_srcdir}/ratio \
${std_srcdir}/regex \
${std_srcdir}/scoped_allocator \
${std_srcdir}/set \
${std_srcdir}/sstream \
${std_srcdir}/stack \
......
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2011 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 <memory>
#include <scoped_allocator>
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_allocator.h>
using __gnu_test::uneq_allocator;
struct Element
{
typedef uneq_allocator<Element> allocator_type;
allocator_type alloc;
Element(const allocator_type& a = allocator_type()) : alloc(a) { }
Element(std::allocator_arg_t, const allocator_type& a, int i = 0)
: alloc(a) { }
Element(std::allocator_arg_t, const allocator_type& a, const Element&)
: alloc(a) { }
const allocator_type& get_allocator() const { return alloc; }
};
void test01()
{
bool test __attribute((unused)) = false;
typedef std::scoped_allocator_adaptor<Element::allocator_type> alloc1_type;
typedef std::vector<Element, alloc1_type> EltVec;
alloc1_type a1(1);
Element e;
EltVec ev1(1, e, a1);
VERIFY( ev1[0].get_allocator().get_personality() == 1 );
}
void test02()
{
bool test __attribute((unused)) = false;
typedef std::vector<Element, Element::allocator_type> EltVec;
typedef std::scoped_allocator_adaptor<EltVec::allocator_type,
Element::allocator_type> alloc_type;
typedef std::vector<EltVec, alloc_type> EltVecVec;
alloc_type a(1, 2);
Element e;
EltVec ev(1, e);
EltVecVec evv(1, ev, a);
VERIFY( evv.get_allocator().get_personality() == 1 );
VERIFY( evv[0].get_allocator().get_personality() == 2 );
VERIFY( evv[0][0].get_allocator().get_personality() == 2 );
alloc_type a2(3, 4);
EltVecVec evv2(evv, a2); // copy with a different allocator
VERIFY( evv2.get_allocator().get_personality() == 3 );
VERIFY( evv2[0].get_allocator().get_personality() == 4 );
VERIFY( evv2[0][0].get_allocator().get_personality() == 4 );
EltVecVec evv3(std::move(evv), a2); // move with a different allocator
VERIFY( evv3.get_allocator().get_personality() == 3 );
VERIFY( evv3[0].get_allocator().get_personality() == 4 );
VERIFY( evv3[0][0].get_allocator().get_personality() == 4 );
}
int main()
{
test01();
}
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2011 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/>.
// test that propagate_on_container_xxx is true iff it is true for
// any of the outer or inner allocators
#include <scoped_allocator>
using std::scoped_allocator_adaptor;
typedef short test_type;
template<typename T>
struct minimal_allocator
{
typedef T value_type;
minimal_allocator();
template <typename U>
minimal_allocator(const minimal_allocator<U>&);
T* allocate(std::size_t);
void deallocate(T*, std::size_t);
};
template<typename T, bool copy, bool move, bool swap>
struct test_allocator : minimal_allocator<T>
{
struct propagate_on_container_copy_assignment
{ static const bool value = copy; };
struct propagate_on_container_move_assignment
{ static const bool value = move; };
struct propagate_on_container_swap
{ static const bool value = swap; };
};
template<typename A>
constexpr bool prop_on_copy()
{
typedef typename A::propagate_on_container_copy_assignment type;
return type::value;
}
template<typename A>
constexpr bool prop_on_move()
{
typedef typename A::propagate_on_container_move_assignment type;
return type::value;
}
template<typename A>
constexpr bool prop_on_swap()
{
typedef typename A::propagate_on_container_swap type;
return type::value;
}
template<typename A, bool C, bool M, bool S>
constexpr bool test1()
{
static_assert( prop_on_copy<A>() == C, "copy" );
static_assert( prop_on_move<A>() == M, "move" );
static_assert( prop_on_swap<A>() == S, "swap" );
return true;
}
template<bool C, bool M, bool S>
constexpr bool test2()
{
typedef minimal_allocator<test_type> base_alloc;
typedef test_allocator<test_type, C, M, S> test_alloc;
typedef scoped_allocator_adaptor<base_alloc, test_alloc> scoped1;
typedef scoped_allocator_adaptor<test_alloc, base_alloc> scoped2;
typedef scoped_allocator_adaptor<test_alloc, test_alloc> scoped3;
return test1<scoped1, C, M, S>()
&& test1<scoped2, C, M, S>()
&& test1<scoped3, C, M, S>();
}
static_assert( test2<false, false, false>(), "never propagate" );
static_assert( test2<true, false, false>(), "propagate on copy" );
static_assert( test2<false, true, false>(), "propagate on move" );
static_assert( test2<false, false, true>(), "propagate on swap" );
static_assert( test2<true, true, false>(), "propagate on copy & move" );
static_assert( test2<true, false, true>(), "propagate on copy & swap" );
static_assert( test2<false, true, true>(), "propagate on move & swap" );
static_assert( test2<true, true, true>(), "always propagate" );
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2011 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/>.
// NB: This file is for testing memory with NO OTHER INCLUDES.
#include <scoped_allocator>
#include <memory>
typedef short test_type;
template<typename T>
struct minimal_allocator
{
typedef T value_type;
minimal_allocator();
template <typename U>
minimal_allocator(const minimal_allocator<U>&);
T* allocate(unsigned long);
void deallocate(T*, unsigned long);
};
namespace std
{
template struct scoped_allocator_adaptor<std::allocator<test_type>>;
template struct scoped_allocator_adaptor<minimal_allocator<test_type>>;
template struct scoped_allocator_adaptor<std::allocator<test_type>,
minimal_allocator<test_type>>;
}
// { dg-options "-std=gnu++0x" }
//
// Copyright (C) 2011 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/>.
//
// NB: This file is for testing scoped_allocator with NO OTHER INCLUDES.
#include <scoped_allocator>
// { dg-do compile }
template<typename T>
struct minimal_allocator
{
typedef T value_type;
minimal_allocator();
template <typename U>
minimal_allocator(const minimal_allocator<U>&);
T* allocate(unsigned long);
void deallocate(T*, unsigned long);
};
struct S
{
typedef minimal_allocator<short> allocator_type;
S(const allocator_type&);
};
void test01()
{
typedef minimal_allocator<S> outer_type;
typedef minimal_allocator<S::allocator_type> inner_type;
typedef std::scoped_allocator_adaptor<outer_type, inner_type> test_type;
// Check for required typedefs
typedef typename test_type::outer_allocator_type outer_allocator_type;
typedef typename test_type::inner_allocator_type inner_allocator_type;
typedef typename test_type::value_type value_type;
typedef typename test_type::size_type size_type;
typedef typename test_type::difference_type difference_type;
typedef typename test_type::pointer pointer;
typedef typename test_type::const_pointer const_pointer;
typedef typename test_type::void_pointer void_pointer;
typedef typename test_type::const_void_pointer const_void_pointer;
typedef typename test_type::propagate_on_container_copy_assignment
propagate_on_container_copy_assignment;
typedef typename test_type::propagate_on_container_move_assignment
propagate_on_container_move_assignment;
typedef typename test_type::propagate_on_container_swap
propagate_on_container_swap;
}
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