if-then-else

suggest change

The type std::conditional (C++11, in the header <type_traits>) selects one type or the other from a compile-time boolean value:

template<typename T>
struct ValueOrPointer
{
    typename std::conditional<(sizeof(T) > sizeof(void*)), T*, T>::type vop;
};

This class template stores a pointer to T when T is larger than a pointer; otherwise, it stores T directly. Consequently, sizeof(ValueOrPointer<T>) is no greater than sizeof(void*).

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents