Commit ce796131 by Paolo Carlini Committed by Paolo Carlini

type_traits (__decay_selector<_Up, [...]): Change according to DR 705.

2007-11-08  Paolo Carlini  <pcarlini@suse.de>

	* include/std/type_traits (__decay_selector<_Up, false, false>):
	Change according to DR 705.
	* include/bits/stl_pair.h (make_pair(_T1&&, _T2&&)): Change
	according to DR 706.
	* include/tr1_impl/tuple: Tweak.

From-SVN: r130001
parent 71733172
2007-11-08 Paolo Carlini <pcarlini@suse.de>
* include/std/type_traits (__decay_selector<_Up, false, false>):
Change according to DR 705.
* include/bits/stl_pair.h (make_pair(_T1&&, _T2&&)): Change
according to DR 706.
* include/tr1_impl/tuple: Tweak.
2007-11-08 Paolo Carlini <pcarlini@suse.de>
* include/debug/vector (push_back, emplace): Fix signature typo.
2007-11-08 Paolo Carlini <pcarlini@suse.de>
......
......@@ -211,14 +211,44 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
make_pair(_T1 __x, _T2 __y)
{ return pair<_T1, _T2>(__x, __y); }
#else
template<typename _Tp>
class reference_wrapper;
// Helper which adds a reference to a type when given a reference_wrapper
template<typename _Tp>
struct __strip_reference_wrapper
{
typedef _Tp __type;
};
template<typename _Tp>
struct __strip_reference_wrapper<reference_wrapper<_Tp> >
{
typedef _Tp& __type;
};
template<typename _Tp>
struct __strip_reference_wrapper<const reference_wrapper<_Tp> >
{
typedef _Tp& __type;
};
template<typename _Tp>
struct __decay_and_strip
{
typedef typename __strip_reference_wrapper<
typename decay<_Tp>::type>::__type __type;
};
// NB: DR 706.
template<class _T1, class _T2>
inline pair<typename std::decay<_T1>::type,
typename std::decay<_T2>::type>
inline pair<typename __decay_and_strip<_T1>::__type,
typename __decay_and_strip<_T2>::__type>
make_pair(_T1&& __x, _T2&& __y)
{
return pair<typename std::decay<_T1>::type,
typename std::decay<_T2>::type>(std::forward<_T1>(__x),
std::forward<_T2>(__y));
return pair<typename __decay_and_strip<_T1>::__type,
typename __decay_and_strip<_T2>::__type>
(std::forward<_T1>(__x), std::forward<_T2>(__y));
}
#endif
......
......@@ -308,21 +308,21 @@ namespace std
bool _IsFunction = is_function<_Up>::value>
struct __decay_selector;
// NB: DR 705.
template<typename _Up>
struct __decay_selector<_Up, false, false>
{ typedef _Up __type; };
{ typedef typename remove_cv<_Up>::type __type; };
template<typename _Up>
struct __decay_selector<_Up, true, false>
{ typedef typename remove_extent<_Up>::type* __type; };
template<typename _Up>
struct __decay_selector<_Up, false, true>
{ typedef typename add_pointer<_Up>::type __type; };
template<typename _Tp>
struct decay
struct decay
{
private:
typedef typename remove_reference<_Tp>::type __remove_type;
......
......@@ -39,9 +39,6 @@ namespace std
{
_GLIBCXX_BEGIN_NAMESPACE_TR1
template<typename _Tp>
class reference_wrapper;
// Adds a const reference to a non-reference type.
template<typename _Tp>
struct __add_c_ref
......@@ -375,6 +372,10 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
const tuple<_UElements...>& __u)
{ return !(__t < __u); }
#ifdef _GLIBCXX_INCLUDE_AS_TR1
template<typename _Tp>
class reference_wrapper;
// Helper which adds a reference to a type when given a reference_wrapper
template<typename _Tp>
struct __strip_reference_wrapper
......@@ -393,6 +394,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
{
typedef _Tp& __type;
};
#endif
template<typename... _Elements>
inline tuple<typename __strip_reference_wrapper<_Elements>::__type...>
......
......@@ -34,8 +34,9 @@ void test01()
typedef decay<bool>::type test1_type;
VERIFY( (is_same<test1_type, bool>::value) );
// NB: DR 705.
typedef decay<const int>::type test2_type;
VERIFY( (is_same<test2_type, const int>::value) );
VERIFY( (is_same<test2_type, int>::value) );
typedef decay<int[4]>::type test3_type;
VERIFY( (is_same<test3_type, std::remove_extent<int[4]>::type*>::value) );
......
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