custom_manip.hpp 1.9 KB

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