Boost logo

Boost :

Subject: Re: [boost] [local] Help for the Alternatives section
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-05-12 14:05:59


On Thu, May 12, 2011 at 9:05 AM, lcaminiti <lorcaminiti_at_[hidden]> wrote:

>
> Jeffrey Lee Hellrung, Jr.-2 wrote:
> >
> > On Fri, May 6, 2011 at 7:59 PM, Lorenzo Caminiti
> > &lt;lorcaminiti_at_[hidden]&gt;wrote:
> >
> >> On Fri, May 6, 2011 at 2:07 PM, Lorenzo Caminiti
> >> &lt;lorcaminiti_at_[hidden]&gt;
> >> wrote:
> >> > On Fri, May 6, 2011 at 1:32 PM, Jeffrey Lee Hellrung, Jr.
> >> > &lt;jeffrey.hellrung_at_[hidden]&gt; wrote:
> >> >> Would "const bind(int)& x" work?
> >>
> >> It think yes :) I should be able to support the syntax (also with
> >> optional leading const and optional &):
> >>
> >> bind& x // deduced type (with Boost.Typeof)
> >> bind(int)& x // specify type (no Boost.Typeof)
> >>
> >> More in general "[const] bind [(type)] [&] name" where "[t]" indicates
> >> that token t is optional.
> >>
> > [...snip preprocessor details...]
> >
> > Awesome.
> >
>
> I have implemented this:
>
>
> http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html#boost_local.Advanced_Topics.specifying_bound_types
>

Great!

Looks like a typo in the 4th bind use case:

const bind(variable-type)& variable-name // Bind by constant value with
explicit type.

Should be "...by reference-to-const..." or "...by constant reference..."
(depending on how you refer to such references throughout the
documentation), eh?

> #include &lt;boost/local/function.hpp&gt;
> #include &lt;boost/local/block.hpp&gt;
> #include &lt;boost/local/exit.hpp&gt;
> #include <vector>
> #include <algorithm>
> #include <iostream>
> #include <sstream>
> #include <cassert>
>
> class adder {
> public:
> adder(): sum_(0.0) {}
>
> double sum(const std::vector<double>& nums, const int& factor = 10) {
> std::ostringstream out;
>
> void BOOST_LOCAL_FUNCTION_PARAMS(double num,
> const bind(const int&) factor, // Specify bind types
> bind(std::ostringstream)& out, // explicitly (so no
>

I would infer from this and the documentation that

    const bind(const int&) factor // outer const superfluous???
    bind(const int&) factor
    const bind(const int)& factor // outer const superfluous???
    bind(const int)& factor
    const bind(int)& factor
    bind(const int&) const factor // outer const superfluous???
    bind(int) const & factor

are all equivalent, but I'm not sure. Can you please clarify in the
documentation?

[...snip rest of example...]

- Jeff


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