expression_holder.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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: 74248 $
  10. //
  11. // Description : toolbox implementation details
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_TOOLS_DETAIL_EXPRESSION_HOLDER_HPP_012705GER
  14. #define BOOST_TEST_TOOLS_DETAIL_EXPRESSION_HOLDER_HPP_012705GER
  15. #ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
  16. #include <boost/test/detail/suppress_warnings.hpp>
  17. //____________________________________________________________________________//
  18. namespace boost {
  19. namespace test_tools {
  20. namespace tt_detail {
  21. // ************************************************************************** //
  22. // ************** tt_detail::expression_holder ************** //
  23. // ************************************************************************** //
  24. class expression_holder {
  25. public:
  26. virtual ~expression_holder() {}
  27. virtual assertion_result evaluate( bool no_message = false ) const = 0;
  28. };
  29. //____________________________________________________________________________//
  30. template<typename E>
  31. class expression_holder_t: public expression_holder {
  32. public:
  33. explicit expression_holder_t( E const& e ) : m_expr( e ) {}
  34. private:
  35. virtual assertion_result evaluate( bool no_message = false ) const { return m_expr.evaluate( no_message ); }
  36. E m_expr;
  37. };
  38. //____________________________________________________________________________//
  39. template<typename E>
  40. expression_holder_t<E>
  41. hold_expression( E const& e )
  42. {
  43. return expression_holder_t<E>( e );
  44. }
  45. //____________________________________________________________________________//
  46. } // namespace tt_detail
  47. } // namespace test_tools
  48. } // namespace boost
  49. #include <boost/test/detail/enable_warnings.hpp>
  50. #endif
  51. #endif // BOOST_TEST_TOOLS_DETAIL_EXPRESSION_HOLDER_HPP_012705GER