I've puzzled over this meta-function for a long time. It seems to work, but I suspect it to contain UB, when it checks for size of a possibly undefined reference type? Is there a problem with this meta-function?
template <class S, class C, typename = void>
struct is_streamable : ::std::false_type { };
template <class S, class C>
struct is_streamable<S,
C,
decltype(void(sizeof(decltype(::std::declval<S&>() <<
::std::declval<C const&>()))))
> : ::std::true_type
{
};
EDIT: The motivation for my question (and worries) was this question. Why did he not use a similar trick (checking size of a reference type)?