1 // Copyright (c) 2001-2011 Hartmut Kaiser
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #if !defined(BOOST_SPIRIT_KARMA_AS_STRING_DEC_18_0644PM)
7 #define BOOST_SPIRIT_KARMA_AS_STRING_DEC_18_0644PM
13 #include <boost/spirit/home/support/unused.hpp>
14 #include <boost/spirit/home/support/attributes_fwd.hpp>
16 ///////////////////////////////////////////////////////////////////////////////
17 namespace boost { namespace spirit { namespace traits
19 ///////////////////////////////////////////////////////////////////////////
20 // This file contains the attribute to string conversion utility. The
21 // utility provided also accept spirit's unused_type; all no-ops. Compiler
22 // optimization will easily strip these away.
23 ///////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////
26 template <typename T, typename Attribute>
27 inline typename spirit::result_of::attribute_as<T, Attribute>::type
28 as(Attribute const& attr)
30 return attribute_as<T, Attribute>::call(attr);
34 inline unused_type as(unused_type)
39 ///////////////////////////////////////////////////////////////////////////
40 template <typename T, typename Attribute>
41 inline bool valid_as(Attribute const& attr)
43 return attribute_as<T, Attribute>::is_valid(attr);
47 inline bool valid_as(unused_type)
53 ///////////////////////////////////////////////////////////////////////////////
54 namespace boost { namespace spirit { namespace result_of
56 template <typename T, typename Attribute>
58 : traits::attribute_as<T, Attribute>
62 struct attribute_as<T, unused_type>
64 typedef unused_type type;
68 struct attribute_as<T, unused_type const>
70 typedef unused_type type;