help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with functor in g++


From: Paul Pluzhnikov
Subject: Re: Problem with functor in g++
Date: Mon, 23 Oct 2006 06:43:13 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

okronglis@hurco.com writes:

> I am having trouble compiling some templated code that uses functors in
> g++.  It compiles fine in VC8.

Really? I though MicroSoft cleaned up its act WRT binding non-const
references to temporaries, but apparently not.

> Any idea what I could do to make this work with g++?

Binding temporary objects to non-const references is not allowed.
You need several const qualifiers:

> class add
> {
> public:
    T& operator()(T& t1, const T& t_inc) const { ... }
...
>   template <class output_functor>
    void do_loop(const output_functor& o)
...
> struct output
> {
    void operator()(const int n) const { ... }

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]