Boost.Range and result_type

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Boost.Range and result_type

Boost - Users mailing list
Hi All

I have a suspicion this is all ancient history now, but I was surprised this code worked.

#include <iostream>
#include <vector>
#include <boost/range/adaptor/transformed.hpp>

struct TimesTwo
{
  // using result_type = int;
  int operator( )( int i ) const { return i * 2; }
};

int main( )
{
  using namespace std;
  using namespace boost::adaptors;

  vector<int> v { 0, 1, 2, 3, 4, 5 };
  for( int i : v | transformed( TimesTwo( ) ) ) { cout << i << " "; } 
  cout << endl;
}

Due to result_type being commented out. Am I right in thinking this is what BOOST_RESULT_OF_USE_DECLTYPE was all about, and everything now just works because modern compilers are implemtenting decltype now?


Kind Regards

Rob.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost.Range and result_type

Boost - Users mailing list
Robert Jones via Boost-users wrote:
> Am I right in thinking this is what BOOST_RESULT_OF_USE_DECLTYPE was all about,
> and everything now just works because modern compilers are implemtenting decltype now?

Yes. If you do
  #define BOOST_RESULT_OF_USE_TR1
the code should fail to compile.

Regards,
Michel
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users