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-30 15:22:22


On Mon, 30 Sep 2013 05:24:45 -0700, Rob Stewart
<robertstewart_at_[hidden]> wrote:

> On Sep 29, 2013, at 11:00 PM, Mostafa <mostafa_working_away_at_[hidden]>
> wrote:
>
>> 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&)
>>
>> 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?
>
> #include<boost/call_traits.hpp>
> ...
> boost::call_traits<typename T::bar>::param_type
>

I should have been more specific, bar is some member function of T. So in
Foo:mybar, the goal is to reconstruct T::bar's paramtypes as "efficient
types". That's what the other person's post was also referring to. So if a
client passes the following struct as a template parameter to Foo:

struct ClientClass
{
   static void bar(int const) { ... }
};

the library is able to instantiate the following Foo::mybar

void Foo::mybar(int const & x) { ClientClass::bar(x); }


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