noncopyable.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Boost noncopyable.hpp header file --------------------------------------//
  2. // (C) Copyright Beman Dawes 1999-2003. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/utility for documentation.
  6. #ifndef BOOST_NONCOPYABLE_HPP_INCLUDED
  7. #define BOOST_NONCOPYABLE_HPP_INCLUDED
  8. #include <boost/config.hpp>
  9. namespace boost {
  10. // Private copy constructor and copy assignment ensure classes derived from
  11. // class noncopyable cannot be copied.
  12. // Contributed by Dave Abrahams
  13. namespace noncopyable_ // protection from unintended ADL
  14. {
  15. class noncopyable
  16. {
  17. protected:
  18. #ifndef BOOST_NO_DEFAULTED_FUNCTIONS
  19. BOOST_CONSTEXPR noncopyable() = default;
  20. ~noncopyable() = default;
  21. #else
  22. noncopyable() {}
  23. ~noncopyable() {}
  24. #endif
  25. #ifndef BOOST_NO_DELETED_FUNCTIONS
  26. noncopyable( const noncopyable& ) = delete;
  27. noncopyable& operator=( const noncopyable& ) = delete;
  28. #else
  29. private: // emphasize the following members are private
  30. noncopyable( const noncopyable& );
  31. noncopyable& operator=( const noncopyable& );
  32. #endif
  33. };
  34. }
  35. typedef noncopyable_::noncopyable noncopyable;
  36. } // namespace boost
  37. #endif // BOOST_NONCOPYABLE_HPP_INCLUDED