Boost logo

Boost :

From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2007-07-07 03:16:58


Ei Martin!

On 7/6/07, Martin Bonner <Martin.Bonner_at_[hidden]> wrote:
>
> I don't think so. The call:
> method(placeholder);
> is "potentially evaluated" and hence the name "placeholder" is "used"
> (see 3.2/2 of the standard) and 3.2/3 says:
> "Every program shall contain exactly one definition of every non-inline
> function or object that is used in that
> program; no diagnostic required."
>

Wow, hmmm... Okay. I don't think I understand why MSVC isn't "smart
enough" to figure that 'placeholder' is just being used or linked to
anywhere in the program except for type deduction while GCC (4.1.2)
deals with this quite "intelligently".

> > Is there a better way of going about
> > this?
>
> I think we need more background. Options:
> - Define 'placeholder'
> - Change the declarations to
> extern a_type* placeholder (and define placeholder to
> null somewhere).
> some_type<T> method(T*) { return some_type<T>(); };
> - Make 'method' take no arguments and explicit specify the
> template arguments.
> - Something else.

As for background, I'm trying to achieve what Boost.Bind does with:
boost::bind(&function, _1, _2) -- where _1 and _2 are used mainly as
placeholders -- without having to resort to unnamed namespaces
(namespace { ... }) to avoid ODR violation. I'm looking at doing
something (for the network library I'm working on):

  network::message m;
  m << transform(to_upper_, headers_);

In the above, to_upper_ and headers_ are placeholders which are used
mainly for type deduction -- while transform returns an instance of a
type (a functor) with template parameters dependent on the types of
to_upper_ and headers_.

I've been successful with using extern placeholders in GCC, and during
link time I don't encounter the errors which I encounter with MSVC. I
now need to find a way of doing this another way.

Any ideas?

Thanks for the clarifications.

-- 
Dean Michael C. Berris
http://cplusplus-soup.blogspot.com/
mikhailberis AT gmail DOT com
+63 928 7291459

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk