|
Boost : |
Subject: Re: [boost] [result_of] Usage guidelines
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2012-09-04 04:06:32
On 04/09/2012 08:59, Andrey Semashev wrote:
> I suppose, in such cases additional
> specializations are still needed:
>
> struct my_foo
> {
> template< typename >
> struct result;
>
> template< typename ArgT >
> struct result< my_foo(ArgT const&) >;
I assume you meant
template< typename ArgT >
struct result< my_foo(ArgT const&) >
{
typedef ArgT type;
};
there?
>
> template< typename ArgT >
> struct result< my_foo(ArgT&) >
> {
> typedef ArgT type;
> };
>
> template< typename ArgT >
> ArgT operator() (ArgT& arg) const
> {
> return arg;
> }
> };
1) doesn't support result_of<my_foo(int)>
2) not always the same type as what operator() returns (consider a const
lvalue passed to operator())
3) needless repetition
You probably wanted to write
struct my_foo
{
template<class Sig>
struct result;
template<class This, class A0>
struct result<This(A0)> : strip<A0> {};
template<class A0>
typename remove_const<A0>::type operator()(A0& a0) const
{
return a0;
}
};
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk