custom_manip.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // (C) Copyright Gennadiy Rozental 2005-2008.
  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 : $RCSfile$
  8. //
  9. // Version : $Revision: 49312 $
  10. //
  11. // Description : simple helpers for creating cusom output manipulators
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_CUSTOM_MANIP_HPP_071894GER
  14. #define BOOST_TEST_CUSTOM_MANIP_HPP_071894GER
  15. // STL
  16. #include <iosfwd>
  17. #include <boost/test/detail/suppress_warnings.hpp>
  18. //____________________________________________________________________________//
  19. namespace boost {
  20. namespace unit_test {
  21. // ************************************************************************** //
  22. // ************** custom manipulators helpers ************** //
  23. // ************************************************************************** //
  24. template<typename Manip>
  25. struct custom_printer {
  26. explicit custom_printer( std::ostream& ostr ) : m_ostr( &ostr ) {}
  27. std::ostream& operator*() const { return *m_ostr; }
  28. private:
  29. std::ostream* const m_ostr;
  30. };
  31. //____________________________________________________________________________//
  32. template<typename Uniq> struct custom_manip {};
  33. //____________________________________________________________________________//
  34. template<typename Uniq>
  35. inline custom_printer<custom_manip<Uniq> >
  36. operator<<( std::ostream& ostr, custom_manip<Uniq> const& ) { return custom_printer<custom_manip<Uniq> >( ostr ); }
  37. //____________________________________________________________________________//
  38. } // namespace unit_test
  39. } // namespace boost
  40. //____________________________________________________________________________//
  41. #include <boost/test/detail/enable_warnings.hpp>
  42. #endif // BOOST_TEST_CUSTOM_MANIP_HPP_071894GER