Boost logo

Boost Users :

Subject: [Boost-users] Boost.Range and result_type
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2018-04-17 10:45:34


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 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