// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2011-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
// .
// test that propagate_on_container_xxx is true iff it is true for
// any of the outer or inner allocators
#include
using std::scoped_allocator_adaptor;
typedef short test_type;
template
struct minimal_allocator
{
typedef T value_type;
minimal_allocator();
template
minimal_allocator(const minimal_allocator&);
T* allocate(std::size_t);
void deallocate(T*, std::size_t);
};
template
struct test_allocator : minimal_allocator
{
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
constexpr bool prop_on_copy()
{
typedef typename A::propagate_on_container_copy_assignment type;
return type::value;
}
template
constexpr bool prop_on_move()
{
typedef typename A::propagate_on_container_move_assignment type;
return type::value;
}
template
constexpr bool prop_on_swap()
{
typedef typename A::propagate_on_container_swap type;
return type::value;
}
template
constexpr bool test1()
{
static_assert( prop_on_copy() == C, "copy" );
static_assert( prop_on_move() == M, "move" );
static_assert( prop_on_swap() == S, "swap" );
return true;
}
template
constexpr bool test2()
{
typedef minimal_allocator base_alloc;
typedef test_allocator test_alloc;
typedef scoped_allocator_adaptor scoped1;
typedef scoped_allocator_adaptor scoped2;
typedef scoped_allocator_adaptor scoped3;
return test1()
&& test1()
&& test1();
}
static_assert( test2(), "never propagate" );
static_assert( test2(), "propagate on copy" );
static_assert( test2(), "propagate on move" );
static_assert( test2(), "propagate on swap" );
static_assert( test2(), "propagate on copy & move" );
static_assert( test2(), "propagate on copy & swap" );
static_assert( test2(), "propagate on move & swap" );
static_assert( test2(), "always propagate" );