token_equal.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef BOOST_MPL_AUX_PREPROCESSOR_TOKEN_EQUAL_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_PREPROCESSOR_TOKEN_EQUAL_HPP_INCLUDED
  3. // Copyright Paul Mensonides 2003
  4. // Copyright Aleksey Gurtovoy 2003-2004
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/mpl for documentation.
  11. // $Id$
  12. // $Date$
  13. // $Revision$
  14. #include <boost/mpl/aux_/preprocessor/is_seq.hpp>
  15. #include <boost/preprocessor/if.hpp>
  16. #include <boost/preprocessor/logical/bitand.hpp>
  17. #include <boost/preprocessor/logical/compl.hpp>
  18. #include <boost/preprocessor/tuple/eat.hpp>
  19. #include <boost/preprocessor/cat.hpp>
  20. // compares tokens 'a' and 'b' for equality:
  21. //
  22. // #define BOOST_MPL_PP_TOKEN_EQUAL_apple(x) x
  23. // #define BOOST_MPL_PP_TOKEN_EQUAL_orange(x) x
  24. //
  25. // BOOST_PP_ASSERT( BOOST_PP_NOT( BOOST_MPL_PP_TOKEN_EQUAL(apple, abc) ) )
  26. // BOOST_PP_ASSERT( BOOST_PP_NOT( BOOST_MPL_PP_TOKEN_EQUAL(abc, apple) ) )
  27. // BOOST_PP_ASSERT( BOOST_PP_NOT( BOOST_MPL_PP_TOKEN_EQUAL(apple, orange) ) )
  28. // BOOST_PP_ASSERT( BOOST_MPL_PP_TOKEN_EQUAL(apple, apple) )
  29. // BOOST_PP_ASSERT( BOOST_MPL_PP_TOKEN_EQUAL(orange, orange) )
  30. #define BOOST_MPL_PP_TOKEN_EQUAL(a, b) \
  31. BOOST_PP_IIF( \
  32. BOOST_PP_BITAND( \
  33. BOOST_MPL_PP_IS_SEQ( BOOST_PP_CAT(BOOST_MPL_PP_TOKEN_EQUAL_, a)((unused)) ) \
  34. , BOOST_MPL_PP_IS_SEQ( BOOST_PP_CAT(BOOST_MPL_PP_TOKEN_EQUAL_, b)((unused)) ) \
  35. ) \
  36. , BOOST_MPL_PP_TOKEN_EQUAL_I \
  37. , 0 BOOST_PP_TUPLE_EAT(2) \
  38. )(a, b) \
  39. /**/
  40. #define BOOST_MPL_PP_TOKEN_EQUAL_I(a, b) \
  41. BOOST_PP_COMPL(BOOST_MPL_PP_IS_SEQ( \
  42. BOOST_MPL_PP_TOKEN_EQUAL_ ## a( \
  43. BOOST_MPL_PP_TOKEN_EQUAL_ ## b \
  44. )((unused)) \
  45. )) \
  46. /**/
  47. #endif // BOOST_MPL_AUX_PREPROCESSOR_TOKEN_EQUAL_HPP_INCLUDED