i'm trying to get used to some tmp concepts.
Here is one solution to check if 2 Types are assignable: This is the most important part:
template<typename _Tp, typename _Up>
class __is_assignable_helper: public __sfinae_types {
template<typename _Tp1, typename _Up1>
static decltype(std::declval<_Tp1>() = std::declval<_Up1>(), __one())
__test(int) {}
template<typename, typename>
static __two __test(...) {}
public:
static constexpr bool value = sizeof(__test<_Tp, _Up>(0)) == 1;
};
Now i tried to use some other sfinae tricks but it doesn't work ..
template<typename _Tp, typename _Up, typename = void>
class __is_assignable_helper2
{
public:
static constexpr bool value = false;
};
template<typename _Tp, typename _Up>
class __is_assignable_helper2<_Tp, _Up,
typename std::enable_if<
std::is_same<typename
decltype(std::declval<_Tp>()= std::declval<_Up>(), char)
,char >::value
, void
>::type>
{
public:
static constexpr bool value = true;
};
GCC says: error: wrong number of template arguments (1, should be2) >::value
.. He doesnt accept the decltype as template parameter in is_same.
Could someone explain this error message ? and suggest a solution ?
UPDATE:
OK ! It works ! i wrote char , instead of char{}....
Next Problem:
Is there a more elegant implementation ?