Use std::addressof in insert iterators, allocators and promises
PR libstdc++/69105 PR libstdc++/69106 PR libstdc++/69114 * include/bits/stl_iterator.h (back_insert_iterator, front_insert_iterator, insert_iterator): Use __addressof (LWG 2324). * include/bits/uses_allocator.h (__use_alloc): Use __addressof. * include/std/future (__future::base::_State_baseV2::__setter): Likewise. * include/std/scoped_allocator (__outermost): Likewise. * testsuite/20_util/scoped_allocator/69114.cc: New. * testsuite/20_util/uses_allocator/69114.cc: New. * testsuite/30_threads/promise/69106.cc: New. From-SVN: r232129
This commit is contained in:
parent
64d3ef31df
commit
f885fa898f
@ -1,3 +1,18 @@
|
||||
2016-01-07 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/69105
|
||||
PR libstdc++/69106
|
||||
PR libstdc++/69114
|
||||
* include/bits/stl_iterator.h (back_insert_iterator,
|
||||
front_insert_iterator, insert_iterator): Use __addressof (LWG 2324).
|
||||
* include/bits/uses_allocator.h (__use_alloc): Use __addressof.
|
||||
* include/std/future (__future::base::_State_baseV2::__setter):
|
||||
Likewise.
|
||||
* include/std/scoped_allocator (__outermost): Likewise.
|
||||
* testsuite/20_util/scoped_allocator/69114.cc: New.
|
||||
* testsuite/20_util/uses_allocator/69114.cc: New.
|
||||
* testsuite/30_threads/promise/69106.cc: New.
|
||||
|
||||
2016-01-06 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/69092
|
||||
|
@ -451,7 +451,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
/// The only way to create this %iterator is with a container.
|
||||
explicit
|
||||
back_insert_iterator(_Container& __x) : container(&__x) { }
|
||||
back_insert_iterator(_Container& __x)
|
||||
: container(std::__addressof(__x)) { }
|
||||
|
||||
/**
|
||||
* @param __value An instance of whatever type
|
||||
@ -541,7 +542,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
typedef _Container container_type;
|
||||
|
||||
/// The only way to create this %iterator is with a container.
|
||||
explicit front_insert_iterator(_Container& __x) : container(&__x) { }
|
||||
explicit front_insert_iterator(_Container& __x)
|
||||
: container(std::__addressof(__x)) { }
|
||||
|
||||
/**
|
||||
* @param __value An instance of whatever type
|
||||
@ -640,7 +642,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
* initial position (a normal %iterator into the container).
|
||||
*/
|
||||
insert_iterator(_Container& __x, typename _Container::iterator __i)
|
||||
: container(&__x), iter(__i) {}
|
||||
: container(std::__addressof(__x)), iter(__i) {}
|
||||
|
||||
/**
|
||||
* @param __value An instance of whatever type
|
||||
|
@ -99,7 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
__use_alloc(const _Alloc& __a)
|
||||
{
|
||||
__uses_alloc_t<_Tp, _Alloc, _Args...> __ret;
|
||||
__ret._M_a = &__a;
|
||||
__ret._M_a = std::__addressof(__a);
|
||||
return __ret;
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
static _Setter<_Res, _Arg&&>
|
||||
__setter(promise<_Res>* __prom, _Arg&& __arg)
|
||||
{
|
||||
return _Setter<_Res, _Arg&&>{ __prom, &__arg };
|
||||
return _Setter<_Res, _Arg&&>{ __prom, std::__addressof(__arg) };
|
||||
}
|
||||
|
||||
template<typename _Res>
|
||||
|
@ -50,7 +50,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
template<typename _Alloc>
|
||||
inline auto
|
||||
__do_outermost(_Alloc& __a, _Alloc*) -> decltype(__a.outer_allocator())
|
||||
__do_outermost(_Alloc& __a, int) -> decltype(__a.outer_allocator())
|
||||
{ return __a.outer_allocator(); }
|
||||
|
||||
template<typename _Alloc>
|
||||
@ -61,8 +61,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
// TODO: make recursive (see note in 20.12.4/1)
|
||||
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, 0))
|
||||
{ return __do_outermost(__a, 0); }
|
||||
|
||||
template<typename _OuterAlloc, typename... _InnerAllocs>
|
||||
class scoped_allocator_adaptor;
|
||||
|
50
libstdc++-v3/testsuite/20_util/scoped_allocator/69114.cc
Normal file
50
libstdc++-v3/testsuite/20_util/scoped_allocator/69114.cc
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (C) 2016 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/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++11" }
|
||||
|
||||
// PR libstdc++/69114
|
||||
|
||||
#include <scoped_allocator>
|
||||
|
||||
template<typename T>
|
||||
struct Alloc
|
||||
{
|
||||
using value_type = T;
|
||||
|
||||
Alloc() = default;
|
||||
|
||||
template<typename U>
|
||||
Alloc(const Alloc<U>&) { }
|
||||
|
||||
T* allocate(std::size_t);
|
||||
void deallocate(T*, std::size_t);
|
||||
|
||||
bool operator==(const Alloc&) const { return true; }
|
||||
bool operator!=(const Alloc&) const { return false; }
|
||||
|
||||
void operator&() = delete;
|
||||
};
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
using alloc_type = Alloc<std::pair<int, int>>;
|
||||
std::scoped_allocator_adaptor<alloc_type> a;
|
||||
a.construct(a.allocate(1));
|
||||
}
|
49
libstdc++-v3/testsuite/20_util/uses_allocator/69114.cc
Normal file
49
libstdc++-v3/testsuite/20_util/uses_allocator/69114.cc
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2016 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/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++11" }
|
||||
|
||||
// PR libstdc++/69114
|
||||
|
||||
#include <tuple>
|
||||
|
||||
template<typename T>
|
||||
struct Alloc
|
||||
{
|
||||
using value_type = T;
|
||||
|
||||
Alloc() = default;
|
||||
|
||||
template<typename U>
|
||||
Alloc(const Alloc<U>&) { }
|
||||
|
||||
T* allocate(std::size_t);
|
||||
void deallocate(T*, std::size_t);
|
||||
|
||||
bool operator==(const Alloc&) const { return true; }
|
||||
bool operator!=(const Alloc&) const { return false; }
|
||||
|
||||
void operator&() = delete;
|
||||
};
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
Alloc<int> a;
|
||||
std::tuple<int> t(std::allocator_arg, a);
|
||||
}
|
34
libstdc++-v3/testsuite/30_threads/promise/69106.cc
Normal file
34
libstdc++-v3/testsuite/30_threads/promise/69106.cc
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2016 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/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=gnu++11" }
|
||||
// { dg-require-cstdint "" }
|
||||
// { dg-require-gthreads "" }
|
||||
// { dg-require-atomic-builtins "" }
|
||||
|
||||
#include <future>
|
||||
|
||||
struct foo {
|
||||
void operator&() const = delete;
|
||||
};
|
||||
|
||||
void test01()
|
||||
{
|
||||
std::promise<foo> p;
|
||||
p.set_value(foo());
|
||||
}
|
Loading…
Reference in New Issue
Block a user