Boost logo

Boost Users :

Subject: Re: [Boost-users] [Fusion] Output of adapted ADT
From: Tore Halvorsen (tore.halvorsen_at_[hidden])
Date: 2011-04-11 03:29:24

On Mon, Apr 11, 2011 at 1:53 AM, Joel de Guzman
<joel_at_[hidden]> wrote:
> On 4/9/2011 3:39 PM, TONGARI wrote:
>> Do you have any suggestion for using adapted class with Spirit that the OP
>> wants to do?
> Well, given the current API, you can write:
>  std::cout << boost::fusion::front(f).get() << std::endl;

Yeah, this works, but I'm still having trouble with karma.

I see that the documentation uses doubles and bools as an example

... but I cannot get ints and strings to work. Am I missing something obvious?

template<typename T>
class sw // simple_wrapper
       sw(T tp) : t(tp) {}
       T const& get() const { return t; }
           void set(T const& tp) { t = tp; }
       T t;

        (T), (sw)(T),
       (T const&, T const&, obj.get(), obj.set(val))

int main()
        using namespace boost::spirit::karma;

        // this works
        sw<bool> const sw_bool(false);
        generate(std::ostream_iterator<char>(std::cout), bool_ << eol, sw_bool);

        // this works
        sw<double> const sw_double(7.7);
        generate(std::ostream_iterator<char>(std::cout), double_ << eol, sw_double);

        // this fails with
        // boost/spirit/home/karma/numeric/detail/numeric_utils.hpp(61):
error C2668: 'fabs' : ambiguous call to overloaded function
        // VC\include\math.h(565): could be 'long double fabs(long double)'
        // VC\include\math.h(517): or 'float fabs(float)'
        // VC\include\math.h(118): or 'double fabs(double)' [found
using argument-dependent lookup]
        // while trying to match the argument list
        sw<int> const sw_int(7);
        generate(std::ostream_iterator<char>(std::cout), int_ << eol, sw_int);

        // this fails with
        // boost/spirit/home/support/container.hpp(174): error C2039: 'const_iterator'
        // : is not a member of
        // with[T=sw<std::string>,N=0,Const=true]
        sw<std::string> const sw_string("foo");
        generate(std::ostream_iterator<char>(std::cout), string << eol, sw_string);


Eld på åren og sol på eng gjer mannen fegen og fjåg. [Jøtul]
<demo> 2011 Tore Halvorsen || +052 0553034554

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at