diff options
author | hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-08-05 14:38:57 +0000 |
---|---|---|
committer | hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-08-05 14:38:57 +0000 |
commit | 374e0781dc6795c78d97f0de8cd2b6873431accb (patch) | |
tree | 3358ab37533d02c8b3f99a2f7f2186b9bb130e3c /libstdc++-v3/include | |
parent | c9a95885532b214c49415e6b80aaaab5a0ce7959 (diff) | |
download | gcc-374e0781dc6795c78d97f0de8cd2b6873431accb.tar.gz |
Merged r150260 through r150468 into branch.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/ifunc@150485 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/forward_list.h | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/move.h | 24 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_iterator.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_list.h | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/safe_iterator.h | 20 | ||||
-rw-r--r-- | libstdc++-v3/include/std/istream | 18 | ||||
-rw-r--r-- | libstdc++-v3/include/std/ostream | 18 | ||||
-rw-r--r-- | libstdc++-v3/include/std/random | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/std/thread | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/std/tuple | 13 |
10 files changed, 101 insertions, 24 deletions
diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h index 724d87b01b1..5158f2dac64 100644 --- a/libstdc++-v3/include/bits/forward_list.h +++ b/libstdc++-v3/include/bits/forward_list.h @@ -1057,7 +1057,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) void splice_after(const_iterator __pos, forward_list&& __list, const_iterator __it) - { this->splice_after(__pos, __list, __it, __it._M_next()); } + { + this->splice_after(__pos, std::forward<forward_list>(__list), + __it, __it._M_next()); + } /** * @brief Insert range from another %forward_list. @@ -1146,7 +1149,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) */ void merge(forward_list&& __list) - { this->merge(__list, std::less<_Tp>()); } + { this->merge(std::forward<forward_list>(__list), std::less<_Tp>()); } /** * @brief Merge sorted lists according to comparison function. diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h index 25773e13c48..e52dec81bc7 100644 --- a/libstdc++-v3/include/bits/move.h +++ b/libstdc++-v3/include/bits/move.h @@ -46,12 +46,30 @@ _GLIBCXX_BEGIN_NAMESPACE(std) typedef _Tp type; }; - /// forward + /// forward (as per N2835) + /// Forward lvalues as rvalues. template<typename _Tp> - inline _Tp&& + inline typename enable_if<!is_lvalue_reference<_Tp>::value, _Tp&&>::type + forward(typename std::identity<_Tp>::type& __t) + { return static_cast<_Tp&&>(__t); } + + /// Forward rvalues as rvalues. + template<typename _Tp> + inline typename enable_if<!is_lvalue_reference<_Tp>::value, _Tp&&>::type forward(typename std::identity<_Tp>::type&& __t) + { return static_cast<_Tp&&>(__t); } + + // Forward lvalues as lvalues. + template<typename _Tp> + inline typename enable_if<is_lvalue_reference<_Tp>::value, _Tp>::type + forward(typename std::identity<_Tp>::type __t) { return __t; } + // Prevent forwarding rvalues as const lvalues. + template<typename _Tp> + inline typename enable_if<is_lvalue_reference<_Tp>::value, _Tp>::type + forward(typename std::remove_reference<_Tp>::type&& __t) = delete; + /** * @brief Move a value. * @ingroup mutating_algorithms @@ -61,7 +79,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<typename _Tp> inline typename std::remove_reference<_Tp>::type&& move(_Tp&& __t) - { return __t; } + { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); } _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 129552f3705..eb7290053ed 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -913,7 +913,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) reference operator*() const - { return *_M_current; } + { return std::move(*_M_current); } pointer operator->() const @@ -973,7 +973,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) reference operator[](difference_type __n) const - { return _M_current[__n]; } + { return std::move(_M_current[__n]); } }; template<typename _IteratorL, typename _IteratorR> diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index f758baed5c9..2a6e58f798f 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -1027,7 +1027,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) insert(iterator __position, size_type __n, const value_type& __x) { list __tmp(__n, __x, _M_get_Node_allocator()); - splice(__position, __tmp); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + splice(__position, std::move(__tmp)); +#else + splice(__position, __tmp); +#endif } /** @@ -1049,7 +1053,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _InputIterator __last) { list __tmp(__first, __last, _M_get_Node_allocator()); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + splice(__position, std::move(__tmp)); +#else splice(__position, __tmp); +#endif } /** diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h index dbdb32e2299..eb0a3e4ae15 100644 --- a/libstdc++-v3/include/debug/safe_iterator.h +++ b/libstdc++-v3/include/debug/safe_iterator.h @@ -115,12 +115,14 @@ namespace __gnu_debug /** * @brief Copy construction. - * @pre @p x is not singular */ _Safe_iterator(const _Safe_iterator& __x) : _Safe_iterator_base(__x, _M_constant()), _M_current(__x._M_current) { - _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector<reverse_iterator<char*> > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x._M_current == _Iterator(), _M_message(__msg_init_copy_singular) ._M_iterator(*this, "this") ._M_iterator(__x, "other")); @@ -129,8 +131,6 @@ namespace __gnu_debug /** * @brief Converting constructor from a mutable iterator to a * constant iterator. - * - * @pre @p x is not singular */ template<typename _MutableIterator> _Safe_iterator( @@ -140,7 +140,10 @@ namespace __gnu_debug _Sequence>::__type>& __x) : _Safe_iterator_base(__x, _M_constant()), _M_current(__x.base()) { - _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector<reverse_iterator<char*> > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _Iterator(), _M_message(__msg_init_const_singular) ._M_iterator(*this, "this") ._M_iterator(__x, "other")); @@ -148,12 +151,14 @@ namespace __gnu_debug /** * @brief Copy assignment. - * @pre @p x is not singular */ _Safe_iterator& operator=(const _Safe_iterator& __x) { - _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector<reverse_iterator<char*> > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x._M_current == _Iterator(), _M_message(__msg_copy_singular) ._M_iterator(*this, "this") ._M_iterator(__x, "other")); @@ -169,7 +174,6 @@ namespace __gnu_debug reference operator*() const { - _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(), _M_message(__msg_bad_deref) ._M_iterator(*this, "this")); diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream index 1979a51327f..2d47b0fd842 100644 --- a/libstdc++-v3/include/std/istream +++ b/libstdc++-v3/include/std/istream @@ -827,6 +827,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std) basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _Traits>& __is); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + // [27.7.1.6] Rvalue stream extraction + /** + * @brief Generic extractor for rvalue stream + * @param is An input stream. + * @param x A reference to the extraction target. + * @return is + * + * This is just a forwarding function to allow extraction from + * rvalue streams since they won't bind to the extractor functions + * that take an lvalue reference. + */ + template<typename _CharT, typename _Traits, typename _Tp> + inline basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) + { return (__is >> __x); } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + _GLIBCXX_END_NAMESPACE #ifndef _GLIBCXX_EXPORT_TEMPLATE diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream index b9ea4a8ce19..9fc693cb3c3 100644 --- a/libstdc++-v3/include/std/ostream +++ b/libstdc++-v3/include/std/ostream @@ -562,6 +562,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std) flush(basic_ostream<_CharT, _Traits>& __os) { return __os.flush(); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + // [27.7.2.9] Rvalue stream insertion + /** + * @brief Generic inserter for rvalue stream + * @param os An input stream. + * @param x A reference to the object being inserted. + * @return os + * + * This is just a forwarding function to allow insertion to + * rvalue streams since they won't bind to the inserter functions + * that take an lvalue reference. + */ + template<typename _CharT, typename _Traits, typename _Tp> + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x) + { return (__os << __x); } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + _GLIBCXX_END_NAMESPACE #ifndef _GLIBCXX_EXPORT_TEMPLATE diff --git a/libstdc++-v3/include/std/random b/libstdc++-v3/include/std/random index 12668583498..b57ef4925d6 100644 --- a/libstdc++-v3/include/std/random +++ b/libstdc++-v3/include/std/random @@ -47,12 +47,18 @@ #include <debug/debug.h> #include <type_traits> +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + +#include <cstdint> // For uint_fast32_t, uint_fast64_t, uint_least32_t + #include <bits/random.h> #ifndef _GLIBCXX_EXPORT_TEMPLATE # include <bits/random.tcc> #endif +#endif // _GLIBCXX_USE_C99_STDINT_TR1 + #endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // _GLIBCXX_RANDOM diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread index bf282cc0365..83b259d7949 100644 --- a/libstdc++-v3/include/std/thread +++ b/libstdc++-v3/include/std/thread @@ -126,7 +126,10 @@ namespace std template<typename _Callable> explicit thread(_Callable __f) - { _M_start_thread(_M_make_routine<_Callable>(__f)); } + { + _M_start_thread(_M_make_routine<_Callable> + (std::forward<_Callable>(__f))); + } template<typename _Callable, typename... _Args> thread(_Callable&& __f, _Args&&... __args) diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 8dc8dcfc064..18cd89bca3b 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -164,7 +164,7 @@ namespace std : _Inherited(__in._M_tail()), _Base(__in._M_head()) { } _Tuple_impl(_Tuple_impl&& __in) - : _Inherited(std::move<_Inherited&&>(__in._M_tail())), + : _Inherited(std::move(__in._M_tail())), _Base(std::forward<_Head>(__in._M_head())) { } template<typename... _UElements> @@ -173,8 +173,7 @@ namespace std template<typename... _UElements> _Tuple_impl(_Tuple_impl<_Idx, _UElements...>&& __in) - : _Inherited(std::move<typename _Tuple_impl<_Idx, _UElements...>:: - _Inherited&&>(__in._M_tail())), + : _Inherited(std::move(__in._M_tail())), _Base(std::forward<typename _Tuple_impl<_Idx, _UElements...>:: _Base>(__in._M_head())) { } @@ -244,7 +243,7 @@ namespace std : _Inherited(static_cast<const _Inherited&>(__in)) { } tuple(tuple&& __in) - : _Inherited(std::move<_Inherited>(__in)) { } + : _Inherited(static_cast<_Inherited&&>(__in)) { } template<typename... _UElements> tuple(const tuple<_UElements...>& __in) @@ -253,7 +252,7 @@ namespace std template<typename... _UElements> tuple(tuple<_UElements...>&& __in) - : _Inherited(std::move<_Tuple_impl<0, _UElements...> >(__in)) { } + : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } // XXX http://gcc.gnu.org/ml/libstdc++/2008-02/msg00047.html template<typename... _UElements> @@ -327,7 +326,7 @@ namespace std : _Inherited(static_cast<const _Inherited&>(__in)) { } tuple(tuple&& __in) - : _Inherited(std::move<_Inherited>(__in)) { } + : _Inherited(static_cast<_Inherited&&>(__in)) { } template<typename _U1, typename _U2> tuple(const tuple<_U1, _U2>& __in) @@ -335,7 +334,7 @@ namespace std template<typename _U1, typename _U2> tuple(tuple<_U1, _U2>&& __in) - : _Inherited(std::move<_Tuple_impl<0, _U1, _U2> >(__in)) { } + : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } template<typename _U1, typename _U2> tuple(const pair<_U1, _U2>& __in) |