lexicographic_manip.hpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // (C) Copyright Gennadiy Rozental 2001.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. //! @file
  8. //! Lexicographic comparison manipulator implementation
  9. // ***************************************************************************
  10. #ifndef BOOST_TEST_TOOLS_DETAIL_LEXICOGRAPHIC_MANIP_HPP_050815GER
  11. #define BOOST_TEST_TOOLS_DETAIL_LEXICOGRAPHIC_MANIP_HPP_050815GER
  12. // Boost Test
  13. #include <boost/test/tools/detail/fwd.hpp>
  14. #include <boost/test/tools/detail/indirections.hpp>
  15. #include <boost/test/tools/assertion.hpp>
  16. #include <boost/test/utils/lazy_ostream.hpp>
  17. #include <boost/test/tools/collection_comparison_op.hpp>
  18. #include <ostream>
  19. #include <boost/test/detail/suppress_warnings.hpp>
  20. //____________________________________________________________________________//
  21. namespace boost {
  22. namespace test_tools {
  23. // ************************************************************************** //
  24. // ************** per element comparison manipulator ************** //
  25. // ************************************************************************** //
  26. //! Lexicographic comparison manipulator, for containers
  27. //! This is a terminal that involves evaluation of the expression
  28. struct lexicographic {};
  29. //____________________________________________________________________________//
  30. inline unit_test::lazy_ostream&
  31. operator<<( unit_test::lazy_ostream & o, lexicographic ) { return o; }
  32. // needed for the lazy evaluation in lazy_ostream as lexicographic is a terminal
  33. inline std::ostream&
  34. operator<<( std::ostream& o, lexicographic ) { return o; }
  35. //____________________________________________________________________________//
  36. namespace tt_detail {
  37. template<typename T1, typename T2, typename OP>
  38. inline assertion_result
  39. operator<<(assertion_evaluate_t<assertion::binary_expr<T1,T2,OP> > const& ae, lexicographic )
  40. {
  41. typedef typename OP::elem_op elem_op;
  42. return assertion::op::lexicographic_compare<elem_op>( ae.m_e.lhs().value(), ae.m_e.rhs() );
  43. }
  44. //____________________________________________________________________________//
  45. inline assertion_type
  46. operator<<( assertion_type const&, lexicographic )
  47. {
  48. return assertion_type(CHECK_BUILT_ASSERTION);
  49. }
  50. //____________________________________________________________________________//
  51. } // namespace tt_detail
  52. } // namespace test_tools
  53. } // namespace boost
  54. #include <boost/test/detail/enable_warnings.hpp>
  55. #endif // BOOST_TEST_TOOLS_DETAIL_LEXICOGRAPHIC_MANIP_HPP_050815GER