lsp_array_cv_test.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // lsp_array_cv_test.cpp
  3. //
  4. // Copyright 2012, 2017 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. //
  10. #include <boost/smart_ptr/local_shared_ptr.hpp>
  11. struct X
  12. {
  13. };
  14. class B
  15. {
  16. };
  17. class D: public B
  18. {
  19. };
  20. #define TEST_CONV( T, U ) \
  21. { \
  22. boost::local_shared_ptr< T > p1; \
  23. boost::local_shared_ptr< U > p2( p1 ); \
  24. p2 = p1; \
  25. boost::local_shared_ptr< U > p3 = boost::local_shared_ptr< T >(); \
  26. p3 = boost::local_shared_ptr< T >(); \
  27. }
  28. #define TEST_CV_TRUE( T, U ) \
  29. TEST_CONV( T, U ) \
  30. TEST_CONV( T, const U ) \
  31. TEST_CONV( T, volatile U ) \
  32. TEST_CONV( T, const volatile U ) \
  33. TEST_CONV( const T, const U ) \
  34. TEST_CONV( const T, const volatile U ) \
  35. TEST_CONV( volatile T, volatile U ) \
  36. TEST_CONV( volatile T, const volatile U ) \
  37. TEST_CONV( const volatile T, const volatile U )
  38. int main()
  39. {
  40. TEST_CV_TRUE( X, X )
  41. TEST_CV_TRUE( X, void )
  42. TEST_CV_TRUE( D, B )
  43. TEST_CV_TRUE( X[], X[] )
  44. TEST_CV_TRUE( X[3], X[3] )
  45. TEST_CV_TRUE( X[3], X[] )
  46. TEST_CV_TRUE( X[], void )
  47. TEST_CV_TRUE( X[3], void )
  48. return 0;
  49. }