Boost logo

Boost :

Subject: Re: [boost] [type_traits][function_types] Discard param const qualification, bug or feature?
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2013-09-29 23:00:55


On Sun, 29 Sep 2013 14:44:52 -0700, Sergey Zhuravlev
<sergey4zhuravlev_at_[hidden]> wrote:

> Signature type int(int, const std::string) can be used as parameter for
> some compiletime algorithm. For example, algorithm that generate new
> signature type with optimal transfer arguments int (int, const
> std::string&) or generate signature with all argument references int
> (int&,
> const std::string&)
> Can't use type_traits, function_types at that cases, because const be
> omitted. This will lead to compiletime error, if function with first
> signature call function with second signature and use arguments from
> function with first signature for this call.

That was exactly the use case and the problem I had. Fortunately for me, I
was able to specify the return type and parameters_type (as an
mpl::vector) separately, which solved the issue. But I don't know if this
is doable in general. For example, what does one do in the following
scenario:

template <typename T>
struct Foo
{
   void mybar( // Construct efficient argument transfer signature for
T::bar )
   { T::bar(....); }
};

without forcing the user to seperately specify T::bar paramtypes as a
separate template parameter?

> Signature type void(int, const std::string) can use as types tuple for
> some
> compiletime algorithm. Can't use type_traits, function_types, at that
> case,
> because const be lost.
>
> Signature type void(int, const std::string) can use as parentheses
> dropper
> for "types list", e.g. for macro parameter. (int, const std::string) =>
> int, const std::string. Can't use type_traits, function_types, at that
> case, because const be lost.
>
> I think default behavior is correct, but need parameter for change this
> behavior. At least function_types.


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