wp_convertible_test.cpp 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <boost/config.hpp>
  2. // wp_convertible_test.cpp
  3. //
  4. // Copyright (c) 2008 Peter Dimov
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. #include <boost/detail/lightweight_test.hpp>
  10. #include <boost/weak_ptr.hpp>
  11. //
  12. class incomplete;
  13. struct X
  14. {
  15. };
  16. struct Y
  17. {
  18. };
  19. struct Z: public X
  20. {
  21. };
  22. int f( boost::weak_ptr<void const> )
  23. {
  24. return 1;
  25. }
  26. int f( boost::weak_ptr<int> )
  27. {
  28. return 2;
  29. }
  30. int f( boost::weak_ptr<incomplete> )
  31. {
  32. return 3;
  33. }
  34. int g( boost::weak_ptr<X> )
  35. {
  36. return 4;
  37. }
  38. int g( boost::weak_ptr<Y> )
  39. {
  40. return 5;
  41. }
  42. int g( boost::weak_ptr<incomplete> )
  43. {
  44. return 6;
  45. }
  46. int main()
  47. {
  48. BOOST_TEST( 1 == f( boost::weak_ptr<double>() ) );
  49. BOOST_TEST( 1 == f( boost::shared_ptr<double>() ) );
  50. BOOST_TEST( 4 == g( boost::weak_ptr<Z>() ) );
  51. BOOST_TEST( 4 == g( boost::shared_ptr<Z>() ) );
  52. return boost::report_errors();
  53. }