Commit dbc6221f by Ville Voutilainen Committed by Ville Voutilainen

Support allocators in tuples of zero size.

	* include/std/tuple (tuple<>::tuple(),
	tuple<>::tuple(allocator_arg_t, const _Alloc&),
	tuple<>::tuple(allocator_arg_t, const _Alloc&, const tuple&)): New.
	* testsuite/20_util/tuple/cons/allocators.cc: Adjust.

From-SVN: r237143
parent 36f9ad69
2016-06-06 Ville Voutilainen <ville.voutilainen@gmail.com>
Support allocators in tuples of zero size.
* include/std/tuple (tuple<>::tuple(),
tuple<>::tuple(allocator_arg_t, const _Alloc&),
tuple<>::tuple(allocator_arg_t, const _Alloc&, const tuple&)): New.
* testsuite/20_util/tuple/cons/allocators.cc: Adjust.
2016-06-06 Jonathan Wakely <jwakely@redhat.com> 2016-06-06 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/71320 PR libstdc++/71320
......
...@@ -876,6 +876,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -876,6 +876,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
public: public:
void swap(tuple&) noexcept { /* no-op */ } void swap(tuple&) noexcept { /* no-op */ }
// We need the default since we're going to define no-op
// allocator constructors.
tuple() = default;
// No-op allocator constructors.
template<typename _Alloc>
tuple(allocator_arg_t, const _Alloc&) { }
template<typename _Alloc>
tuple(allocator_arg_t, const _Alloc&, const tuple&) { }
}; };
/// Partial specialization, 2-element tuple. /// Partial specialization, 2-element tuple.
......
...@@ -162,8 +162,30 @@ void test01() ...@@ -162,8 +162,30 @@ void test01()
} }
void test02()
{
bool test __attribute__((unused)) = true;
using std::allocator_arg;
using std::tuple;
using std::make_tuple;
typedef tuple<> test_type;
MyAlloc a;
// default construction
test_type t1(allocator_arg, a);
// copy construction
test_type t2(allocator_arg, a, t1);
// move construction
test_type t3(allocator_arg, a, std::move(t1));
// make_tuple
test_type empty = make_tuple();
}
int main() int main()
{ {
test01(); test01();
test02();
return 0; return 0;
} }
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