noncopyable.cpp 644 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2006 Arkadiy Vertleyb
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
  4. #include "test.hpp"
  5. #include <boost/noncopyable.hpp>
  6. #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
  7. struct x : boost::noncopyable
  8. {
  9. void foo() {}
  10. void bar() const {}
  11. };
  12. BOOST_TYPEOF_REGISTER_TYPE(x)
  13. x& make_ref()
  14. {
  15. static x result;
  16. return result;
  17. }
  18. const x& make_const_ref()
  19. {
  20. static x result;
  21. return result;
  22. }
  23. void foo()
  24. {
  25. BOOST_AUTO(& v1, make_ref());
  26. v1.foo();
  27. BOOST_AUTO(const& v2, make_const_ref());
  28. v2.bar();
  29. }