File indexing completed on 2025-01-19 09:47:40
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_KARMA_REFERENCE_APR_17_2009_1057PM)
0008 #define BOOST_SPIRIT_KARMA_REFERENCE_APR_17_2009_1057PM
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/spirit/home/karma/meta_compiler.hpp>
0015 #include <boost/spirit/home/karma/generator.hpp>
0016 #include <boost/spirit/home/support/info.hpp>
0017 #include <boost/spirit/home/support/handles_container.hpp>
0018 #include <boost/type_traits/remove_const.hpp>
0019 #include <boost/ref.hpp>
0020
0021 namespace boost { namespace spirit { namespace karma
0022 {
0023
0024
0025
0026 template <typename Subject>
0027 struct reference : generator<reference<Subject> >
0028 {
0029 typedef mpl::int_<generator_properties::all_properties> properties;
0030
0031 typedef Subject subject_type;
0032
0033 reference(Subject& subject)
0034 : ref(subject) {}
0035
0036 template <typename Context, typename Unused>
0037 struct attribute : Subject::template attribute<Context, Unused> {};
0038
0039
0040
0041 template <typename OutputIterator, typename Context
0042 , typename Delimiter, typename Attribute>
0043 bool generate(OutputIterator& sink, Context& context
0044 , Delimiter const& delim, Attribute const& attr) const
0045 {
0046 return ref.get().generate(sink, context, delim, attr);
0047 }
0048
0049
0050
0051 template <typename OutputIterator, typename Context
0052 , typename Delimiter>
0053 bool generate(OutputIterator& sink, Context& context
0054 , Delimiter const& delim, unused_type) const
0055 {
0056 return ref.get().generate(sink, context, delim, context.attributes);
0057 }
0058
0059
0060
0061 template <typename OutputIterator, typename Delimiter>
0062 bool generate(OutputIterator& sink, unused_type
0063 , Delimiter const& delim, unused_type) const
0064 {
0065 return ref.get().generate(sink, unused, delim, unused);
0066 }
0067
0068 template <typename Context>
0069 info what(Context& context) const
0070 {
0071
0072 return ref.get().what(context);
0073 }
0074
0075 boost::reference_wrapper<Subject> ref;
0076 };
0077 }}}
0078
0079 namespace boost { namespace spirit { namespace traits
0080 {
0081
0082 template <typename Subject, typename Attribute, typename Context
0083 , typename Iterator>
0084 struct handles_container<karma::reference<Subject>, Attribute
0085 , Context, Iterator>
0086 : handles_container<typename remove_const<Subject>::type, Attribute
0087 , Context, Iterator>
0088 {};
0089 }}}
0090
0091 #endif