unused.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*=============================================================================
  2. Copyright (c) 2001-2014 Joel de Guzman
  3. Copyright (c) 2001-2011 Hartmut Kaiser
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #if !defined(BOOST_SPIRIT_X3_UNUSED_APRIL_16_2006_0616PM)
  8. #define BOOST_SPIRIT_X3_UNUSED_APRIL_16_2006_0616PM
  9. #include <iosfwd>
  10. ///////////////////////////////////////////////////////////////////////////////
  11. namespace boost { namespace spirit { namespace x3
  12. {
  13. struct unused_type
  14. {
  15. unused_type() = default;
  16. template <typename T>
  17. unused_type(T const&)
  18. {
  19. }
  20. template <typename T>
  21. unused_type const&
  22. operator=(T const&) const
  23. {
  24. return *this;
  25. }
  26. template <typename T>
  27. unused_type&
  28. operator=(T const&)
  29. {
  30. return *this;
  31. }
  32. // unused_type can also masquerade as an empty context (see context.hpp)
  33. template <typename ID>
  34. unused_type get(ID) const
  35. {
  36. return {};
  37. }
  38. };
  39. auto const unused = unused_type{};
  40. inline std::ostream& operator<<(std::ostream& out, unused_type const&)
  41. {
  42. return out;
  43. }
  44. inline std::istream& operator>>(std::istream& in, unused_type&)
  45. {
  46. return in;
  47. }
  48. }}}
  49. #endif