boost_no_dep_nested_class.ipp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // (C) Copyright John Maddock 2001.
  2. // Use, modification and distribution are subject to the
  3. // Boost 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/config for most recent version.
  6. // MACRO: BOOST_NO_DEPENDENT_NESTED_DERIVATIONS
  7. // TITLE: dependent nested template classes
  8. // DESCRIPTION: The compiler fails to compile
  9. // a nested class that has a dependent base class:
  10. // template<typename T>
  11. // struct foo : {
  12. // template<typename U>
  13. // struct bar : public U {};
  14. // };
  15. #ifndef BOOST_NESTED_TEMPLATE
  16. #define BOOST_NESTED_TEMPLATE template
  17. #endif
  18. namespace boost_no_dependent_nested_derivations{
  19. struct UDT1{};
  20. struct UDT2{};
  21. template<typename T>
  22. struct foo
  23. {
  24. template<typename U>
  25. struct bar : public foo<U>
  26. {};
  27. };
  28. template <class T>
  29. void foo_test(T)
  30. {
  31. typedef foo<T> foo_type;
  32. typedef typename foo_type::BOOST_NESTED_TEMPLATE bar<UDT2> bar_type;
  33. foo<T> ft;
  34. bar_type bt;
  35. (void) &bt;
  36. (void) &ft;
  37. }
  38. int test()
  39. {
  40. foo_test(UDT1());
  41. return 0;
  42. }
  43. }