/Src/Dependencies/Boost/boost/spirit/home/support/unused.hpp

http://hadesmem.googlecode.com/ · C++ Header · 105 lines · 73 code · 16 blank · 16 comment · 0 complexity · d2f8c9a8b0da53f6f3ae8878a43282f3 MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2011 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_UNUSED_APRIL_16_2006_0616PM)
  8. #define BOOST_SPIRIT_UNUSED_APRIL_16_2006_0616PM
  9. #if defined(_MSC_VER)
  10. #pragma once
  11. #endif
  12. #include <boost/config.hpp>
  13. #include <boost/mpl/bool.hpp>
  14. #if defined(BOOST_MSVC)
  15. # pragma warning(push)
  16. # pragma warning(disable: 4522) // multiple assignment operators specified warning
  17. #endif
  18. ///////////////////////////////////////////////////////////////////////////////
  19. namespace boost { namespace spirit
  20. {
  21. ///////////////////////////////////////////////////////////////////////////
  22. // We do not import fusion ::unused_type anymore to avoid boost::fusion
  23. // being turned into an associate namespace for boost::spirit, as this
  24. // interferes with ADL in unexpected ways. We rather copy the full
  25. // unused_type implementation from boost::fusion.
  26. ///////////////////////////////////////////////////////////////////////////
  27. struct unused_type
  28. {
  29. unused_type()
  30. {
  31. }
  32. template <typename T>
  33. unused_type(T const&)
  34. {
  35. }
  36. template <typename T>
  37. unused_type const&
  38. operator=(T const&) const
  39. {
  40. return *this;
  41. }
  42. template <typename T>
  43. unused_type&
  44. operator=(T const&)
  45. {
  46. return *this;
  47. }
  48. unused_type const&
  49. operator=(unused_type const&) const
  50. {
  51. return *this;
  52. }
  53. unused_type&
  54. operator=(unused_type const&)
  55. {
  56. return *this;
  57. }
  58. };
  59. unused_type const unused = unused_type();
  60. namespace detail
  61. {
  62. struct unused_only
  63. {
  64. unused_only(unused_type const&) {}
  65. };
  66. }
  67. template <typename Out>
  68. inline Out& operator<<(Out& out, detail::unused_only const&)
  69. {
  70. return out;
  71. }
  72. template <typename In>
  73. inline In& operator>>(In& in, unused_type&)
  74. {
  75. return in;
  76. }
  77. ///////////////////////////////////////////////////////////////////////////
  78. namespace traits
  79. {
  80. // We use this test to detect if the argument is not an unused_type
  81. template <typename T> struct not_is_unused : mpl::true_ {};
  82. template <> struct not_is_unused<unused_type> : mpl::false_ {};
  83. }
  84. }}
  85. #if defined(BOOST_MSVC)
  86. # pragma warning(pop)
  87. #endif
  88. #endif