forked from OSchip/llvm-project
Updated by-chapter chart with weekly test results. Also did some prototyping on result_of, but if-def'd out the prototyped part (which the LWG may or may not accept)
llvm-svn: 111389
This commit is contained in:
parent
eaacbc9da6
commit
5e2f7b89e9
|
@ -1321,6 +1321,71 @@ public:
|
|||
typedef decltype(declval<_Fn>()(declval<_ArgTypes>()...)) type;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
template <class _MP, class _Tp, class ..._Args>
|
||||
struct __result_of_mp;
|
||||
|
||||
// member function pointer
|
||||
|
||||
template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
|
||||
struct __result_of_mp<_R (_Class::*)(_Params...), _Tp, _Args...>
|
||||
{
|
||||
typedef _R type;
|
||||
};
|
||||
|
||||
template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
|
||||
struct __result_of_mp<_R (_Class::*)(_Params...) const, _Tp, _Args...>
|
||||
{
|
||||
typedef _R type;
|
||||
};
|
||||
|
||||
template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
|
||||
struct __result_of_mp<_R (_Class::*)(_Params...) volatile, _Tp, _Args...>
|
||||
{
|
||||
typedef _R type;
|
||||
};
|
||||
|
||||
template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
|
||||
struct __result_of_mp<_R (_Class::*)(_Params...) const volatile, _Tp, _Args...>
|
||||
{
|
||||
typedef _R type;
|
||||
};
|
||||
|
||||
// member data pointer
|
||||
|
||||
template <class _MP, class _Tp, bool>
|
||||
struct __result_of_mdp;
|
||||
|
||||
template <class _R, class _Class, class _Tp>
|
||||
struct __result_of_mdp<_R _Class::*, _Tp, false>
|
||||
{
|
||||
typedef typename __apply_cv<decltype(*_STD::declval<_Tp>()), _R>::type type;
|
||||
};
|
||||
|
||||
template <class _R, class _Class, class _Tp>
|
||||
struct __result_of_mdp<_R _Class::*, _Tp, true>
|
||||
{
|
||||
typedef typename __apply_cv<_Tp, _R>::type&& type;
|
||||
};
|
||||
|
||||
template <class _R, class _Class, class _Tp>
|
||||
struct __result_of_mp<_R _Class::*, _Tp>
|
||||
: public __result_of_mdp<_R _Class::*, _Tp,
|
||||
is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Fn, class _Tp, class ..._ArgTypes>
|
||||
class __result_of<_Fn(_Tp, _ArgTypes...), false> // _Fn must be member pointer
|
||||
: public __result_of_mp<_Fn, _Tp, _ArgTypes...>
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// result_of
|
||||
|
||||
template <class _Fn, class ..._ArgTypes>
|
||||
class result_of<_Fn(_ArgTypes...)>
|
||||
: public __result_of<_Fn(_ArgTypes...),
|
||||
|
|
|
@ -1 +1 @@
|
|||
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// result_of<Fn(ArgTypes...)>
#include <type_traits>
typedef bool (&PF1)();
typedef short (*PF2)(long);
struct S
{
operator PF2() const;
double operator()(char, int&);
};
int main()
{
static_assert((std::is_same<std::result_of<S(int)>::type, short>::value), "Error!");
static_assert((std::is_same<std::result_of<S&(unsigned char, int&)>::type, double>::value), "Error!");
static_assert((std::is_same<std::result_of<PF1()>::type, bool>::value), "Error!");
}
|
||||
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// result_of<Fn(ArgTypes...)>
#include <type_traits>
typedef short (*PF2)(long);
typedef bool (&PF1)();
typedef short (*PF2)(long);
struct S
{
operator PF2() const;
double operator()(char, int&);
void calc(long) const;
char data_;
};
typedef void (S::*PMS)(long) const;
};
int main()
{
static_assert((std::is_same<std::result_of<S(int)>::type, short>::value), "Error!");
static_assert((std::is_same<std::result_of<S&(unsigned char, int&)>::type, double>::value), "Error!");
static_assert((std::is_same<std::result_of<PF1()>::type, bool>::value), "Error!");
// static_assert(std::is_same<std::result_of<PMS(std::unique_ptr<S>, int)>::type, void>::value, "Error!");
// static_assert(std::is_same<std::result_of<PMD(S)>::type, char&&>::value, "Error!");
// static_assert(std::is_same<std::result_of<PMD(const S*)>::type, const char&>::value, "Error!");
}
|
Binary file not shown.
Loading…
Reference in New Issue