symbol.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright (C) 2009-2012 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0
  3. // (see accompanying file LICENSE_1_0.txt or a copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Home at http://www.boost.org/libs/local_function
  6. #ifndef BOOST_LOCAL_FUNCTION_AUX_SYMBOL_HPP_
  7. #define BOOST_LOCAL_FUNCTION_AUX_SYMBOL_HPP_
  8. #include <boost/preprocessor/cat.hpp>
  9. #include <boost/preprocessor/seq/cat.hpp>
  10. #include <boost/preprocessor/seq/transform.hpp>
  11. // PRIVATE //
  12. // NOTE: INFIX is used to separate symbols concatenated together. Some of these
  13. // symbols are user-defined so they can be anything. Because they can contain
  14. // underscore `_` and/or start with capital letters, it is NOT safe for the
  15. // INFIX to be the underscore `_` character because that could lead to library
  16. // defined symbols containing double underscores `__` or a leading underscore
  17. // (followed or not by a capital letter) in the global namespace. All these
  18. // symbols are reserved by the C++ standard: (1) "each name that contains a
  19. // double underscore (_ _) or begins with an underscore followed by an
  20. // uppercase letter is reserved to the implementation" and (2) "each name that
  21. // begins with an underscore is reserved to the implementation for use as a
  22. // name in the global namespace".
  23. #define BOOST_LOCAL_FUNCTION_AUX_SYMBOL_INFIX_ X // `X` used as separator.
  24. #define BOOST_LOCAL_FUNCTION_AUX_SYMBOL_PREFIX_ boost_local_function_aux
  25. #define BOOST_LOCAL_FUNCTION_AUX_SYMBOL_POSTFIX_(s, unused, tokens) \
  26. BOOST_PP_CAT(tokens, BOOST_LOCAL_FUNCTION_AUX_SYMBOL_INFIX_)
  27. // PUBLIC //
  28. // Prefixes this library reserved symbol.
  29. #define BOOST_LOCAL_FUNCTION_AUX_SYMBOL(seq) \
  30. BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_TRANSFORM( \
  31. BOOST_LOCAL_FUNCTION_AUX_SYMBOL_POSTFIX_, \
  32. ~, (BOOST_LOCAL_FUNCTION_AUX_SYMBOL_PREFIX_) seq ))
  33. // Postfixes this library reserved symbol.
  34. #define BOOST_LOCAL_FUNCTION_AUX_SYMBOL_POSTFIX(seq) \
  35. BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_TRANSFORM( \
  36. BOOST_LOCAL_FUNCTION_AUX_SYMBOL_POSTFIX_, \
  37. ~, seq (BOOST_LOCAL_FUNCTION_AUX_SYMBOL_PREFIX_) ))
  38. #endif // #include guard