msvc_is_class.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef BOOST_MPL_AUX_MSVC_IS_CLASS_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_MSVC_IS_CLASS_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2002-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <boost/mpl/if.hpp>
  14. #include <boost/mpl/bool.hpp>
  15. #include <boost/mpl/aux_/type_wrapper.hpp>
  16. #include <boost/mpl/aux_/yes_no.hpp>
  17. #include <boost/type_traits/is_reference.hpp>
  18. namespace boost { namespace mpl { namespace aux {
  19. template< typename T > struct is_class_helper
  20. {
  21. typedef int (T::* type)();
  22. };
  23. // MSVC 6.x-specific lightweight 'is_class' implementation;
  24. // Distinguishing feature: does not instantiate the type being tested.
  25. template< typename T >
  26. struct msvc_is_class_impl
  27. {
  28. template< typename U>
  29. static yes_tag test(type_wrapper<U>*, /*typename*/ is_class_helper<U>::type = 0);
  30. static no_tag test(void const volatile*, ...);
  31. enum { value = sizeof(test((type_wrapper<T>*)0)) == sizeof(yes_tag) };
  32. typedef bool_<value> type;
  33. };
  34. // agurt, 17/sep/04: have to check for 'is_reference' upfront to avoid ICEs in
  35. // complex metaprograms
  36. template< typename T >
  37. struct msvc_is_class
  38. : if_<
  39. is_reference<T>
  40. , false_
  41. , msvc_is_class_impl<T>
  42. >::type
  43. {
  44. };
  45. }}}
  46. #endif // BOOST_MPL_AUX_MSVC_IS_CLASS_HPP_INCLUDED