is_identifier.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // (C) Copyright Edward Diener 2011-2015
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. #if !defined(BOOST_VMD_DETAIL_IS_IDENTIFIER_HPP)
  6. #define BOOST_VMD_DETAIL_IS_IDENTIFIER_HPP
  7. #include <boost/preprocessor/comparison/equal.hpp>
  8. #include <boost/preprocessor/control/iif.hpp>
  9. #include <boost/preprocessor/logical/bitor.hpp>
  10. #include <boost/preprocessor/punctuation/is_begin_parens.hpp>
  11. #include <boost/preprocessor/tuple/elem.hpp>
  12. #include <boost/preprocessor/variadic/size.hpp>
  13. #include <boost/preprocessor/variadic/elem.hpp>
  14. #include <boost/vmd/identity.hpp>
  15. #include <boost/vmd/is_empty.hpp>
  16. #include <boost/vmd/is_tuple.hpp>
  17. #include <boost/vmd/detail/identifier.hpp>
  18. #include <boost/vmd/detail/identifier_concat.hpp>
  19. #include <boost/vmd/detail/not_empty.hpp>
  20. #define BOOST_VMD_DETAIL_IS_IDENTIFIER_VSEQ_MATCH(tup) \
  21. BOOST_VMD_DETAIL_NOT_EMPTY \
  22. ( \
  23. BOOST_PP_TUPLE_ELEM(0,tup) \
  24. ) \
  25. /**/
  26. #define BOOST_VMD_DETAIL_IS_IDENTIFIER_VSEQ_TUPLE(ptup) \
  27. BOOST_VMD_IDENTITY_RESULT \
  28. ( \
  29. BOOST_PP_IIF \
  30. ( \
  31. BOOST_VMD_IS_TUPLE(ptup), \
  32. BOOST_VMD_DETAIL_IS_IDENTIFIER_VSEQ_MATCH, \
  33. BOOST_VMD_IDENTITY(0) \
  34. ) \
  35. (ptup) \
  36. ) \
  37. /**/
  38. #define BOOST_VMD_DETAIL_IS_IDENTIFIER_VSEQ_ID(vseq) \
  39. BOOST_VMD_DETAIL_IS_IDENTIFIER_VSEQ_TUPLE \
  40. ( \
  41. BOOST_VMD_DETAIL_IDENTIFIER_CONCATENATE(vseq) \
  42. ) \
  43. /**/
  44. #define BOOST_VMD_DETAIL_IS_IDENTIFIER_VSEQ(vseq) \
  45. BOOST_VMD_IDENTITY_RESULT \
  46. ( \
  47. BOOST_PP_IIF \
  48. ( \
  49. BOOST_PP_BITOR \
  50. ( \
  51. BOOST_VMD_IS_EMPTY(vseq), \
  52. BOOST_PP_IS_BEGIN_PARENS(vseq) \
  53. ), \
  54. BOOST_VMD_IDENTITY(0), \
  55. BOOST_VMD_DETAIL_IS_IDENTIFIER_VSEQ_ID \
  56. ) \
  57. (vseq) \
  58. ) \
  59. /**/
  60. #define BOOST_VMD_DETAIL_IS_IDENTIFIER_SINGLE(...) \
  61. BOOST_VMD_DETAIL_IS_IDENTIFIER_VSEQ(BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__)) \
  62. /**/
  63. #define BOOST_VMD_DETAIL_IS_IDENTIFIER_SINGLE_D(d,...) \
  64. BOOST_VMD_DETAIL_IS_IDENTIFIER_VSEQ(BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__)) \
  65. /**/
  66. #define BOOST_VMD_DETAIL_IS_IDENTIFIER(...) \
  67. BOOST_PP_IIF \
  68. ( \
  69. BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),1), \
  70. BOOST_VMD_DETAIL_IS_IDENTIFIER_SINGLE, \
  71. BOOST_VMD_DETAIL_IS_IDENTIFIER_MULTIPLE \
  72. ) \
  73. (__VA_ARGS__) \
  74. /**/
  75. #define BOOST_VMD_DETAIL_IS_IDENTIFIER_D(d,...) \
  76. BOOST_PP_IIF \
  77. ( \
  78. BOOST_PP_EQUAL_D(d,BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),1), \
  79. BOOST_VMD_DETAIL_IS_IDENTIFIER_SINGLE_D, \
  80. BOOST_VMD_DETAIL_IS_IDENTIFIER_MULTIPLE_D \
  81. ) \
  82. (d,__VA_ARGS__) \
  83. /**/
  84. #endif /* BOOST_VMD_DETAIL_IS_IDENTIFIER_HPP */