Boost logo

Boost Users :

Subject: Re: [Boost-users] What result_type ? And why?
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2011-07-19 03:34:46


> I wrote the following functor:
>
> struct ASCII_lower
> {
> template< typename CharT >
> CharT operator() (const CharT& ch) const
> {
> if (ch >= 'A' && ch <= 'Z') return ch+0x20;
> return ch; // unchanged
> }
> };
>
> and when I used it to create a transformed_range, I get an error that it doesn't find
> result_type in ASCII_lower.
> Since the return type depends on the argument, how could I declare a result_type?
>
> And why do I need it? Lambda functions don't have it, and I thought it was fairly old
> fashioned and optional for helping figure out the result type if necessary.

In C++0x, it is not necessary to help the compiler figure out the return type
of a functor in any way - it can do it using decltype.
 
To enable this functionality in boost, you need to define the symbol
 
BOOST_RESULT_OF_USE_DECLTYPE
 
Regards,
Nate.


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