Commit dd7b175e by Paolo Carlini Committed by Paolo Carlini

type_traits (__or_, __and_): Add trivial definitions for a single element.

2011-05-30  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/type_traits (__or_, __and_): Add trivial definitions
	for a single element.
	* include/bits/stl_pair.h: Use __and_ in noexcept specs and
	constraints.
	(pair<>::pair(pair&&)): Define.
	(pair<>::pair(const pair<>&)): Constrain with is_convertible.
	(pair<>::pair(pair<>&&)): Likewise, remove noexcept.
	* include/std/tuple: Use __and_ in noexcept specs and constraints.
	(_Tuple_impl<>::_Tuple_impl(allocator_arg_t, const _Alloc&,
	_Tuple_impl&&)): Remove noexcept.
	(tuple<>::tuple(_UElements&&...), tuple(const tuple<_UElements...>&),
	tuple(tuple<_UElements...>&&), tuple(const pair<_U1, _U2>&),
	tuple(pair<_U1, _U2>&&)): Constrain with is_convertible.
	* testsuite/20_util/tuple/moveable2.cc: Use = delete.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
	Likewise.
	* testsuite/20_util/declval/requirements/1_neg.cc: Likewise.
	* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Likewise.
	* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Likewise.

From-SVN: r174464
parent c7dfcaeb
2011-05-30 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/type_traits (__or_, __and_): Add trivial definitions
for a single element.
* include/bits/stl_pair.h: Use __and_ in noexcept specs and
constraints.
(pair<>::pair(pair&&)): Define.
(pair<>::pair(const pair<>&)): Constrain with is_convertible.
(pair<>::pair(pair<>&&)): Likewise, remove noexcept.
* include/std/tuple: Use __and_ in noexcept specs and constraints.
(_Tuple_impl<>::_Tuple_impl(allocator_arg_t, const _Alloc&,
_Tuple_impl&&)): Remove noexcept.
(tuple<>::tuple(_UElements&&...), tuple(const tuple<_UElements...>&),
tuple(tuple<_UElements...>&&), tuple(const pair<_U1, _U2>&),
tuple(pair<_U1, _U2>&&)): Constrain with is_convertible.
* testsuite/20_util/tuple/moveable2.cc: Use = delete.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Adjust dg-error line numbers.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Likewise.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Likewise.
2011-05-31 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/std/tuple: Restore is_convertible constraint.
......
......@@ -105,37 +105,47 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: first(__a), second(__b) { }
/** There is also a templated copy ctor for the @c pair class itself. */
#ifndef __GXX_EXPERIMENTAL_CXX0X__
template<class _U1, class _U2>
_GLIBCXX_CONSTEXPR pair(const pair<_U1, _U2>& __p)
pair(const pair<_U1, _U2>& __p)
: first(__p.first), second(__p.second) { }
#else
template<class _U1, class _U2, class = typename
enable_if<__and_<is_convertible<const _U1&, _T1>,
is_convertible<const _U2&, _T2>>::value>::type>
constexpr pair(const pair<_U1, _U2>& __p)
: first(__p.first), second(__p.second) { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
constexpr pair(const pair&) = default;
// Implicit?!? Breaks containers!!!
// pair(pair&&) = default;
// XXX Defaulted?!? Breaks std::map!!!
pair(pair&& __p)
noexcept(__and_<is_nothrow_move_constructible<_T1>,
is_nothrow_move_constructible<_T2>>::value)
: first(std::forward<first_type>(__p.first)),
second(std::forward<second_type>(__p.second)) { }
// DR 811.
template<class _U1, class = typename
std::enable_if<std::is_convertible<_U1, _T1>::value>::type>
enable_if<is_convertible<_U1, _T1>::value>::type>
pair(_U1&& __x, const _T2& __y)
: first(std::forward<_U1>(__x)), second(__y) { }
template<class _U2, class = typename
std::enable_if<std::is_convertible<_U2, _T2>::value>::type>
enable_if<is_convertible<_U2, _T2>::value>::type>
pair(const _T1& __x, _U2&& __y)
: first(__x), second(std::forward<_U2>(__y)) { }
template<class _U1, class _U2, class = typename
std::enable_if<std::is_convertible<_U1, _T1>::value
&& std::is_convertible<_U2, _T2>::value>::type>
enable_if<__and_<is_convertible<_U1, _T1>,
is_convertible<_U2, _T2>>::value>::type>
pair(_U1&& __x, _U2&& __y)
: first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { }
template<class _U1, class _U2>
template<class _U1, class _U2, class = typename
enable_if<__and_<is_convertible<_U1, _T1>,
is_convertible<_U2, _T2>>::value>::type>
pair(pair<_U1, _U2>&& __p)
noexcept(std::is_nothrow_constructible<_T1, _U1&&>::value
&& std::is_nothrow_constructible<_T2, _U2&&>::value)
: first(std::forward<_U1>(__p.first)),
second(std::forward<_U2>(__p.second)) { }
......@@ -155,11 +165,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
pair&
operator=(pair&& __p)
noexcept(std::is_nothrow_move_assignable<_T1>::value
&& std::is_nothrow_move_assignable<_T2>::value)
noexcept(__and_<is_nothrow_move_assignable<_T1>,
is_nothrow_move_assignable<_T2>>::value)
{
first = std::move(__p.first);
second = std::move(__p.second);
first = std::forward<first_type>(__p.first);
second = std::forward<second_type>(__p.second);
return *this;
}
......@@ -176,8 +186,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
pair&
operator=(pair<_U1, _U2>&& __p)
{
first = std::move(__p.first);
second = std::move(__p.second);
first = std::forward<_U1>(__p.first);
second = std::forward<_U2>(__p.second);
return *this;
}
......
......@@ -59,9 +59,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, _Tp>
struct integral_constant;
template<typename, typename, typename...>
template<typename...>
struct __or_;
template<typename _B1>
struct __or_<_B1>
: public _B1
{ };
template<typename _B1, typename _B2>
struct __or_<_B1, _B2>
: public conditional<_B1::value, _B1, _B2>::type
......@@ -72,9 +77,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
{ };
template<typename, typename, typename...>
template<typename...>
struct __and_;
template<typename _B1>
struct __and_<_B1>
: public _B1
{ };
template<typename _B1, typename _B2>
struct __and_<_B1, _B2>
: public conditional<_B1::value, _B2, _B1>::type
......
......@@ -19,7 +19,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-error "static assertion failed" "" { target *-*-* } 1715 }
// { dg-error "static assertion failed" "" { target *-*-* } 1725 }
#include <utility>
......
......@@ -48,5 +48,5 @@ void test01()
// { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1501 }
// { dg-error "declaration of" "" { target *-*-* } 1465 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1511 }
// { dg-error "declaration of" "" { target *-*-* } 1475 }
......@@ -48,5 +48,5 @@ void test01()
// { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1425 }
// { dg-error "declaration of" "" { target *-*-* } 1389 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1435 }
// { dg-error "declaration of" "" { target *-*-* } 1399 }
......@@ -51,4 +51,4 @@ test04()
// { dg-error "instantiated from here" "" { target *-*-* } 46 }
// { dg-error "denominator cannot be zero" "" { target *-*-* } 268 }
// { dg-error "out of range" "" { target *-*-* } 269 }
// { dg-error "overflow in constant expression" "" { target *-*-* } 99 }
// { dg-error "overflow in constant expression" "" { target *-*-* } 109 }
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// Copyright (C) 2008, 2009, 2010, 2011 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
......@@ -17,7 +17,6 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <tuple>
#include <utility>
......@@ -30,9 +29,8 @@ struct MoveOnly
MoveOnly& operator=(MoveOnly&&)
{ return *this; }
private:
MoveOnly(MoveOnly const&); // = delete
MoveOnly& operator=(MoveOnly const&); // = delete
MoveOnly(MoveOnly const&) = delete;
MoveOnly& operator=(MoveOnly const&) = delete;
};
MoveOnly
......
......@@ -51,9 +51,9 @@ main()
// { dg-warning "note" "" { target *-*-* } 485 }
// { dg-warning "note" "" { target *-*-* } 479 }
// { dg-warning "note" "" { target *-*-* } 469 }
// { dg-warning "note" "" { target *-*-* } 868 }
// { dg-warning "note" "" { target *-*-* } 887 }
// { dg-warning "note" "" { target *-*-* } 1056 }
// { dg-warning "note" "" { target *-*-* } 1050 }
// { dg-warning "note" "" { target *-*-* } 342 }
// { dg-warning "note" "" { target *-*-* } 292 }
// { dg-warning "note" "" { target *-*-* } 214 }
// { dg-warning "note" "" { target *-*-* } 224 }
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