dependent_type.cpp 959 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // (C) Copyright Eric Niebler 2005.
  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. /*
  6. Revision history:
  7. 26 August 2005 : Initial version.
  8. */
  9. #include <vector>
  10. #include <boost/test/minimal.hpp>
  11. #include <boost/foreach.hpp>
  12. ///////////////////////////////////////////////////////////////////////////////
  13. // use FOREACH to iterate over a sequence with a dependent type
  14. template<typename Vector>
  15. void do_test(Vector const & vect)
  16. {
  17. typedef BOOST_DEDUCED_TYPENAME Vector::value_type value_type;
  18. BOOST_FOREACH(value_type i, vect)
  19. {
  20. // no-op, just make sure this compiles
  21. ((void)i);
  22. }
  23. }
  24. ///////////////////////////////////////////////////////////////////////////////
  25. // test_main
  26. //
  27. int test_main( int, char*[] )
  28. {
  29. std::vector<int> vect;
  30. do_test(vect);
  31. return 0;
  32. }