noncopyable_compile_fail.cpp 980 B

123456789101112131415161718192021222324252627282930313233343536
  1. // boost class noncopyable test program ------------------------------------//
  2. // (C) Copyright Beman Dawes 1999. 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 for most recent version including documentation.
  6. // Revision History
  7. // 9 Jun 99 Add unnamed namespace
  8. // 2 Jun 99 Initial Version
  9. #include <boost/noncopyable.hpp>
  10. #include <iostream>
  11. // This program demonstrates compiler errors resulting from trying to copy
  12. // construct or copy assign a class object derived from class noncopyable.
  13. namespace
  14. {
  15. class DontTreadOnMe : private boost::noncopyable
  16. {
  17. public:
  18. DontTreadOnMe() { std::cout << "defanged!" << std::endl; }
  19. }; // DontTreadOnMe
  20. } // unnamed namespace
  21. int main()
  22. {
  23. DontTreadOnMe object1;
  24. DontTreadOnMe object2(object1);
  25. object1 = object2;
  26. return 0;
  27. } // main