// <scoped_allocator> -*- C++ -*-
-// Copyright (C) 2011 Free Software Foundation, Inc.
+// Copyright (C) 2011, 2012 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
template<typename _Alloc>
inline auto
- __do_outermost(_Alloc& __a, _Alloc&) -> decltype(__a.outer_allocator())
+ __do_outermost(_Alloc& __a, _Alloc*) -> decltype(__a.outer_allocator())
{ return __a.outer_allocator(); }
template<typename _Alloc>
template<typename _Alloc>
inline auto
- __outermost(_Alloc& __a) -> decltype(__do_outermost(__a, __a))
- { return __do_outermost(__a, __a); }
+ __outermost(_Alloc& __a) -> decltype(__do_outermost(__a, &__a))
+ { return __do_outermost(__a, &__a); }
template<typename _OuterAlloc, typename... _InnerAllocs>
class scoped_allocator_adaptor;
// { dg-options "-std=gnu++0x" }
-// Copyright (C) 2011 Free Software Foundation, Inc.
+// Copyright (C) 2011, 2012 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
Element(const allocator_type& a = allocator_type()) : alloc(a) { }
- Element(std::allocator_arg_t, const allocator_type& a, int i = 0)
+ Element(std::allocator_arg_t, const allocator_type& a, int = 0)
: alloc(a) { }
Element(std::allocator_arg_t, const allocator_type& a, const Element&)
alloc1_type a1(1);
Element e;
EltVec ev1(1, e, a1);
+ VERIFY( ev1.get_allocator().get_personality() == 1 );
VERIFY( ev1[0].get_allocator().get_personality() == 1 );
}
{
bool test __attribute((unused)) = false;
- typedef std::vector<Element, Element::allocator_type> EltVec;
+ typedef std::scoped_allocator_adaptor<Element::allocator_type> inner_alloc_type;
- typedef std::scoped_allocator_adaptor<EltVec::allocator_type,
- Element::allocator_type> alloc_type;
+ typedef std::vector<Element, inner_alloc_type> EltVec;
+
+ typedef std::scoped_allocator_adaptor<Element::allocator_type,
+ Element::allocator_type> alloc_type;
typedef std::vector<EltVec, alloc_type> EltVecVec;
- alloc_type a(1, 2);
+ alloc_type a(1, Element::allocator_type(2)); // outer=1, inner=2
Element e;
EltVec ev(1, e);
EltVecVec evv(1, ev, a);
VERIFY( evv[0].get_allocator().get_personality() == 2 );
VERIFY( evv[0][0].get_allocator().get_personality() == 2 );
- alloc_type a2(3, 4);
+ alloc_type a2(3, Element::allocator_type(4)); // outer=3, inner=4
EltVecVec evv2(evv, a2); // copy with a different allocator
int main()
{
test01();
+ test02();
}