classifier.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // (C) Copyright Tobias Schwinger
  2. //
  3. // Use modification and distribution are subject to the boost Software License,
  4. // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
  5. //------------------------------------------------------------------------------
  6. #ifndef BOOST_FT_DETAIL_CLASSIFIER_HPP_INCLUDED
  7. #define BOOST_FT_DETAIL_CLASSIFIER_HPP_INCLUDED
  8. #include <boost/type.hpp>
  9. #include <boost/config.hpp>
  10. #include <boost/type_traits/is_reference.hpp>
  11. #include <boost/type_traits/add_reference.hpp>
  12. #include <boost/function_types/config/config.hpp>
  13. #include <boost/function_types/property_tags.hpp>
  14. namespace boost { namespace function_types { namespace detail {
  15. template<typename T> struct classifier;
  16. template<std::size_t S> struct char_array { typedef char (&type)[S]; };
  17. template<bits_t Flags, bits_t CCID, std::size_t Arity> struct encode_charr
  18. {
  19. typedef typename char_array<
  20. ::boost::function_types::detail::encode_charr_impl<Flags,CCID,Arity>::value
  21. >::type type;
  22. };
  23. #if defined(BOOST_MSVC) || (defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32))
  24. # define BOOST_FT_DECL __cdecl
  25. #else
  26. # define BOOST_FT_DECL /**/
  27. #endif
  28. char BOOST_FT_DECL classifier_impl(...);
  29. #define BOOST_FT_variations BOOST_FT_function|BOOST_FT_pointer|\
  30. BOOST_FT_member_pointer
  31. #define BOOST_FT_type_function(cc,name) BOOST_FT_SYNTAX( \
  32. R BOOST_PP_EMPTY,BOOST_PP_LPAREN,cc,* BOOST_PP_EMPTY,name,BOOST_PP_RPAREN)
  33. #define BOOST_FT_type_function_pointer(cc,name) BOOST_FT_SYNTAX( \
  34. R BOOST_PP_EMPTY,BOOST_PP_LPAREN,cc,** BOOST_PP_EMPTY,name,BOOST_PP_RPAREN)
  35. #define BOOST_FT_type_member_function_pointer(cc,name) BOOST_FT_SYNTAX( \
  36. R BOOST_PP_EMPTY,BOOST_PP_LPAREN,cc,T0::** BOOST_PP_EMPTY,name,BOOST_PP_RPAREN)
  37. #define BOOST_FT_al_path boost/function_types/detail/classifier_impl
  38. #include <boost/function_types/detail/pp_loop.hpp>
  39. template<typename T> struct classifier_bits
  40. {
  41. static typename boost::add_reference<T>::type tester;
  42. BOOST_STATIC_CONSTANT(bits_t,value = (bits_t)sizeof(
  43. boost::function_types::detail::classifier_impl(& tester)
  44. )-1);
  45. };
  46. template<typename T> struct classifier
  47. {
  48. typedef detail::constant<
  49. ::boost::function_types::detail::decode_bits<
  50. ::boost::function_types::detail::classifier_bits<T>::value
  51. >::tag_bits >
  52. bits;
  53. typedef detail::full_mask mask;
  54. typedef detail::constant<
  55. ::boost::function_types::detail::decode_bits<
  56. ::boost::function_types::detail::classifier_bits<T>::value
  57. >::arity >
  58. function_arity;
  59. };
  60. } } } // namespace ::boost::function_types::detail
  61. #endif