delete.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2012 Vicente J. Botet Escriba
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_THREAD_DETAIL_DELETE_HPP
  6. #define BOOST_THREAD_DETAIL_DELETE_HPP
  7. #include <boost/config.hpp>
  8. /**
  9. * BOOST_THREAD_DELETE_COPY_CTOR deletes the copy constructor when the compiler supports it or
  10. * makes it private.
  11. *
  12. * BOOST_THREAD_DELETE_COPY_ASSIGN deletes the copy assignment when the compiler supports it or
  13. * makes it private.
  14. */
  15. #if ! defined BOOST_NO_CXX11_DELETED_FUNCTIONS && ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
  16. #define BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \
  17. CLASS(CLASS const&) = delete; \
  18. #define BOOST_THREAD_DELETE_COPY_ASSIGN(CLASS) \
  19. CLASS& operator=(CLASS const&) = delete;
  20. #else // BOOST_NO_CXX11_DELETED_FUNCTIONS
  21. #if defined(BOOST_MSVC) && _MSC_VER >= 1600
  22. #define BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \
  23. private: \
  24. CLASS(CLASS const&); \
  25. public:
  26. #define BOOST_THREAD_DELETE_COPY_ASSIGN(CLASS) \
  27. private: \
  28. CLASS& operator=(CLASS const&); \
  29. public:
  30. #else
  31. #define BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \
  32. private: \
  33. CLASS(CLASS&); \
  34. public:
  35. #define BOOST_THREAD_DELETE_COPY_ASSIGN(CLASS) \
  36. private: \
  37. CLASS& operator=(CLASS&); \
  38. public:
  39. #endif
  40. #endif // BOOST_NO_CXX11_DELETED_FUNCTIONS
  41. /**
  42. * BOOST_THREAD_NO_COPYABLE deletes the copy constructor and assignment when the compiler supports it or
  43. * makes them private.
  44. */
  45. #define BOOST_THREAD_NO_COPYABLE(CLASS) \
  46. BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \
  47. BOOST_THREAD_DELETE_COPY_ASSIGN(CLASS)
  48. #endif // BOOST_THREAD_DETAIL_DELETE_HPP