mirror of git://gcc.gnu.org/git/gcc.git
any (any::_Manager_alloc::_Data): Reorder tuple members to simplify pretty printing.
* include/experimental/any (any::_Manager_alloc::_Data): Reorder tuple members to simplify pretty printing. (any::_Manager_alloc::_Data::_M_construct): Fix uses-allocator construction. * testsuite/experimental/any/cons/4.cc: New. From-SVN: r212435
This commit is contained in:
parent
218e53ea1f
commit
7757d79bfc
|
|
@ -1,3 +1,11 @@
|
||||||
|
2014-07-10 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
* include/experimental/any (any::_Manager_alloc::_Data): Reorder
|
||||||
|
tuple members to simplify pretty printing.
|
||||||
|
(any::_Manager_alloc::_Data::_M_construct): Fix uses-allocator
|
||||||
|
construction.
|
||||||
|
* testsuite/experimental/any/cons/4.cc: New.
|
||||||
|
|
||||||
2014-07-09 Jason Merrill <jason@redhat.com>
|
2014-07-09 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
PR libstdc++/61728
|
PR libstdc++/61728
|
||||||
|
|
|
||||||
|
|
@ -450,18 +450,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
{
|
{
|
||||||
using _Traits = std::allocator_traits<_Alloc>;
|
using _Traits = std::allocator_traits<_Alloc>;
|
||||||
|
|
||||||
std::tuple<_Alloc, __gnu_cxx::__aligned_buffer<_Tp>> _M_data;
|
std::tuple<__gnu_cxx::__aligned_buffer<_Tp>, _Alloc> _M_data;
|
||||||
|
|
||||||
_Alloc& _M_alloc() { return std::get<0>(_M_data); }
|
_Alloc& _M_alloc() { return std::get<1>(_M_data); }
|
||||||
const _Alloc& _M_alloc() const { return std::get<0>(_M_data); }
|
const _Alloc& _M_alloc() const { return std::get<1>(_M_data); }
|
||||||
|
|
||||||
_Tp* _M_obj() { return std::get<1>(_M_data)._M_ptr(); }
|
_Tp* _M_obj() { return std::get<0>(_M_data)._M_ptr(); }
|
||||||
const _Tp* _M_obj() const { return std::get<1>(_M_data)._M_ptr(); }
|
const _Tp* _M_obj() const { return std::get<0>(_M_data)._M_ptr(); }
|
||||||
|
|
||||||
template<typename _Up>
|
template<typename _Up>
|
||||||
_Data(const _Alloc& __a, _Up&& __val) : _M_data(__a, nullptr)
|
_Data(const _Alloc& __a, _Up&& __val) : _M_data(nullptr, __a)
|
||||||
{
|
{
|
||||||
this->_M_construct(std::__use_alloc<_Tp>(_M_alloc()),
|
this->_M_construct(std::__use_alloc<_Tp, _Alloc, _Up&&>(_M_alloc()),
|
||||||
std::forward<_Up>(__val));
|
std::forward<_Up>(__val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -479,8 +479,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
void
|
void
|
||||||
_M_construct(__uses_alloc1<_Alloc> __a, _Up&& __val)
|
_M_construct(__uses_alloc1<_Alloc> __a, _Up&& __val)
|
||||||
{
|
{
|
||||||
_Traits::construct(__a._M_a, _M_obj(),
|
_Traits::construct(_M_alloc(), _M_obj(),
|
||||||
std::allocator_arg, __a._M_a,
|
std::allocator_arg, *__a._M_a,
|
||||||
std::forward<_Up>(__val));
|
std::forward<_Up>(__val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -488,8 +488,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
void
|
void
|
||||||
_M_construct(__uses_alloc2<_Alloc> __a, _Up&& __val)
|
_M_construct(__uses_alloc2<_Alloc> __a, _Up&& __val)
|
||||||
{
|
{
|
||||||
_Traits::construct(__a._M_a, _M_obj(),
|
_Traits::construct(_M_alloc(), _M_obj(),
|
||||||
std::forward<_Up>(__val), __a._M_a);
|
std::forward<_Up>(__val), *__a._M_a);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
// { 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 <memory>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
using std::experimental::any;
|
||||||
|
|
||||||
|
struct NotSmall
|
||||||
|
{
|
||||||
|
char c[64]; // prevent small-object optimization
|
||||||
|
};
|
||||||
|
|
||||||
|
struct T1
|
||||||
|
{
|
||||||
|
using allocator_type = std::allocator<char>;
|
||||||
|
|
||||||
|
T1() = default;
|
||||||
|
T1(const T1&) : used_alloc(false) { }
|
||||||
|
T1(const T1&, const allocator_type&) : used_alloc(true) { }
|
||||||
|
|
||||||
|
bool used_alloc;
|
||||||
|
|
||||||
|
NotSmall x;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct T2
|
||||||
|
{
|
||||||
|
using allocator_type = std::allocator<char>;
|
||||||
|
|
||||||
|
T2() = default;
|
||||||
|
T2(const T2&) : used_alloc(false) { }
|
||||||
|
T2(std::allocator_arg_t, const allocator_type&, const T2&) : used_alloc(true)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
bool used_alloc;
|
||||||
|
|
||||||
|
NotSmall x;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool test [[gnu::unused]] = true;
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
any x1(std::allocator_arg, std::allocator<char>{}, T1{});
|
||||||
|
VERIFY( std::experimental::any_cast<T1&>(x1).used_alloc );
|
||||||
|
|
||||||
|
any x2(std::allocator_arg, std::allocator<char>{}, T2{});
|
||||||
|
VERIFY( std::experimental::any_cast<T2&>(x2).used_alloc );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue