unused.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #if defined(BOOST_MSVC)
  11. # pragma warning(push)
  12. # pragma warning(disable: 4522) // multiple assignment operators specified warning
  13. #endif
  14. ///////////////////////////////////////////////////////////////////////////////
  15. namespace boost { namespace spirit { namespace x3
  16. {
  17. struct unused_type
  18. {
  19. unused_type()
  20. {
  21. }
  22. template <typename T>
  23. unused_type(T const&)
  24. {
  25. }
  26. template <typename T>
  27. unused_type const&
  28. operator=(T const&) const
  29. {
  30. return *this;
  31. }
  32. template <typename T>
  33. unused_type&
  34. operator=(T const&)
  35. {
  36. return *this;
  37. }
  38. unused_type const&
  39. operator=(unused_type const&) const
  40. {
  41. return *this;
  42. }
  43. unused_type&
  44. operator=(unused_type const&)
  45. {
  46. return *this;
  47. }
  48. // unused_type can also masquerade as an empty context (see context.hpp)
  49. template <typename ID>
  50. unused_type get(ID) const
  51. {
  52. return {};
  53. }
  54. };
  55. auto const unused = unused_type{};
  56. inline std::ostream& operator<<(std::ostream& out, unused_type const&)
  57. {
  58. return out;
  59. }
  60. inline std::istream& operator>>(std::istream& in, unused_type&)
  61. {
  62. return in;
  63. }
  64. }}}
  65. #if defined(BOOST_MSVC)
  66. # pragma warning(pop)
  67. #endif
  68. #endif