Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2006-09-27 13:22:00

The BOOST_PARAMETER_KEYWORD(tag, name) macro expands, in part, to
something like:

keyword<tag::name> & name = ...;

Shouldn't this be:

keyword<tag::name> const & name = ...;

What is the reason for using a non-const ref here? These things are not
mutable. In fact, it is causing me problems. Consider a placeholder type
with an implicit conversion operator:

struct default_constructed_t {
     template<typename T>
     operator T() const {
         return T();

default_constructed_t const default_constructed = {};


Now, when I do this: "value = default_constructed;" I get this error:

main.cpp:306: error: ISO C++ says that these are ambiguous, even though
the worst conversion for the first is better than the worst conversion
for the second:
keyword.hpp:59: note: candidate 1: const typename
boost::parameter::aux::tag<Tag, const T>::type
boost::parameter::keyword<T>::operator=(const T&) const [with T =
default_constructed_t, Tag = tag::value]
keyword.hpp:32: note: candidate 2:

Had the keyword object been const, the call would not have been ambiguous.

Eric Niebler
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at