Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2007-09-26 18:38:19


on Wed Sep 26 2007, Jean-Christophe Roux <jcxxr-AT-yahoo.com> wrote:

> Hello,
>
> Thank you for the parameter library; it is making my library much nicer
> to use. Two questions:
> 1. I am assuming there is no runtime penalty to use the BOOST_PARAMETER
> version of a function. Is that right?

In the performance tests we ran, with optimization and inlining on,
there was zero or negative (yes, negative!) performance penalty.

http://svn.boost.org/trac/boost/browser/trunk/libs/parameter/test/efficiency.cpp

> 2. My code looks like that:
> namespace keywords
> {
> BOOST_PARAMETER_NAME(id)
> BOOST_PARAMETER_NAME(test)
> }
> BOOST_PARAMETER_FUNCTION
> (
> (void),foo,keywords::tag, (optional (id, *, "")
> (test, (const char*), "")
> )
> )
> {
> ...
> }
> Here the parameters must be converted, if necessary, to const char*
> in order to be used later. What would be the best way to write the
> requirement that the type must be const char* or must be convertible to
> const char*?

Just use the declaration as you have written it. Inside your function
the test parameter will be of type const char*, but outside it will
accept anything convertible to const char*.

HTH,

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net