相关疑难解决方法(0)

如何确定C++ 03中的类型是否可解除引用?

C++ 03中,如何确定类型T是否可解除引用?
我的意思是,我如何静态地确定是否*tt类型的有效表达式T

我的尝试:

template<bool B, class T = void> struct enable_if { };
template<class T> struct enable_if<true, T> { typedef T type; };

unsigned char (&helper(void const *))[2];
template<class T>
typename enable_if<
    !!sizeof(**static_cast<T *>(NULL)),
    unsigned char
>::type helper(T *);

template<class T>
struct is_dereferenceable
{ static bool const value = sizeof(helper(static_cast<T *>(NULL))) == 1; };

struct Test
{
    int *operator *();
    void operator *() const;
private:
    Test(Test const &);
}; …
Run Code Online (Sandbox Code Playgroud)

c++ dereference

7
推荐指数
1
解决办法
410
查看次数

标签 统计

c++ ×1

dereference ×1