Boost logo

Boost Users :

Subject: [Boost-users] boost::tr1::tuple or boost::tuple? how to compile the same code with both -std=c++98 and -std=c++11?
From: Frédéric Bron (frederic.bron_at_[hidden])
Date: 2013-09-12 11:20:23


This small program compiles nicely with g++ 4.6.4 and -std=c++98 and
boost 1.52.0:

#include <iostream>
#include <boost/math/tools/roots.hpp>
#include <boost/tr1/tuple.hpp>

std::tr1::tuple<double, double> f(double x) {
    return std::tr1::tuple<double, double>(x, 1.);
}
int main() {
    std::cout<<boost::math::tools::newton_raphson_iterate(f, 10., -9.,
+20., 10);
    return 0;
}

Now, I would like to be able to compile that program also with g++
4.8.1 and -std=c++11 (I changed also boost to 1.53.0).

If I do not change anything, std::tr1::tuple is replaced by std::tuple
and I get the following error (see attached log):
path/to/boost/include/boost/math/tools/roots.hpp:202:32: error: no
match for 'operator=' (operand types are 'std::tuple<double&,
double&>' and 'boost::fusion::tuple<double, double>')

I tried to replace <boost/tr1/tuple.hpp> and std::tr1::tuple by
<boost/tuple/tuple.hpp> and boost::tuple without any success.

What should I do to have the same code compile with both -std=c++98
and -std=c++11?

Regards,

Frédéric




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