var.hpp 985 B

12345678910111213141516171819202122232425262728293031323334
  1. /*=============================================================================
  2. Copyright (c) 2003 Martin Wille
  3. http://spirit.sourceforge.net/
  4. Use, modification and distribution is subject to the Boost Software
  5. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. =============================================================================*/
  8. #ifndef BOOST_SPIRIT_TEST_IMPL_VAR_HPP
  9. #define BOOST_SPIRIT_TEST_IMPL_VAR_HPP
  10. #include <boost/ref.hpp>
  11. namespace test
  12. {
  13. template <typename T>
  14. struct var_wrapper
  15. : public ::boost::reference_wrapper<T>
  16. {
  17. typedef ::boost::reference_wrapper<T> parent;
  18. explicit inline var_wrapper(T& t) : parent(t) {}
  19. inline T& operator()() const { return parent::get(); }
  20. };
  21. template <typename T>
  22. inline var_wrapper<T>
  23. var(T& t)
  24. {
  25. return var_wrapper<T>(t);
  26. }
  27. }
  28. #endif // BOOST_SPIRIT_TEST_IMPL_VAR_HPP