#include #include #include #include #include namespace private_ns{ typedef char (&funny_size)[7919]; // large prime number, very rair in practice template funny_size operator*(const T&); template struct is_dereferencable_imp { static T& object; static const bool value = sizeof(*object) != sizeof(funny_size); }; template struct is_dereferencable_imp { static const bool value = ::boost::is_pointer::value; }; } template struct is_dereferencable { typedef typename boost::remove_reference::type no_ref_type; typedef typename boost::remove_cv::type base_type; static const bool value = private_ns::is_dereferencable_imp::value>::value; }; struct B{}; int operator*(B&) { return 0; } struct C{}; typedef int B::*mp; typedef int (B::*pmf)(int); typedef void (*pf)(); int main() { // false std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; // true std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable >::value << std::endl; std::cout << is_dereferencable >::value << std::endl; std::cout << is_dereferencable >::value << std::endl; std::cout << is_dereferencable::value << std::endl; // false std::cout << is_dereferencable::value << std::endl; std::cout << is_dereferencable::value << std::endl; }