1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3     Copyright (c) 2001-2011 Hartmut Kaiser
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(BOOST_SPIRIT_UNUSED_APRIL_16_2006_0616PM)
9 #define BOOST_SPIRIT_UNUSED_APRIL_16_2006_0616PM
10 
11 #if defined(_MSC_VER)
12 #pragma once
13 #endif
14 
15 #include <boost/config.hpp>
16 #include <boost/mpl/bool.hpp>
17 
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     {
unused_typeboost::spirit::unused_type29         BOOST_DEFAULTED_FUNCTION(unused_type(), {})
30 
31         template <typename T>
32         unused_type(T const&)
33         {
34         }
35 
36         template <typename T>
37         unused_type const&
operator =boost::spirit::unused_type38         operator=(T const&) const
39         {
40             return *this;
41         }
42 
43         template <typename T>
44         unused_type&
operator =boost::spirit::unused_type45         operator=(T const&)
46         {
47             return *this;
48         }
49     };
50 
51     unused_type const unused = unused_type();
52 
53     namespace detail
54     {
55         struct unused_only
56         {
unused_onlyboost::spirit::detail::unused_only57             unused_only(unused_type const&) {}
58         };
59     }
60 
61     template <typename Out>
operator <<(Out & out,detail::unused_only const &)62     inline Out& operator<<(Out& out, detail::unused_only const&)
63     {
64         return out;
65     }
66 
67     template <typename In>
operator >>(In & in,unused_type &)68     inline In& operator>>(In& in, unused_type&)
69     {
70         return in;
71     }
72 
73     ///////////////////////////////////////////////////////////////////////////
74     namespace traits
75     {
76         // We use this test to detect if the argument is not an unused_type
77         template <typename T> struct not_is_unused : mpl::true_ {};
78         template <> struct not_is_unused<unused_type> : mpl::false_ {};
79     }
80 }}
81 
82 #endif
83