roboptim-core icon indicating copy to clipboard operation
roboptim-core copied to clipboard

C++11?

Open bchretien opened this issue 9 years ago • 5 comments

cc @thomas-moulard

C++14 is out, and the urge to use C++11 features is getting strong. What is currently stopping us from moving to C++11? Ubuntu 12.04's GCC? Most features seem to be available with GCC 4.6, and that may be all we need at first.

bchretien avatar Sep 24 '14 18:09 bchretien

Mainly ABI compatibility, compiler quality and compatibility with old platforms. C++0x is still considered "experimental" in GCC. Cf http://stackoverflow.com/questions/20373626/why-c11-compiler-support-still-requires-a-flag/20373913#20373913

For Ubuntu 12.04 in particular the features may be here but I am really not sure if it is reasonable to use them or not due to potential bugs. Personally, I installed gcc 4.8 from a PPA since I started using C++11. It may not be an acceptable solution for people linking against system libraries though.

However I do know how painful it is not to use C++11 so one possibility is to add optional C++11 features (compiled if enabled).

Another possibility is to switch anyway. I am not against it but it is better to confirm with people at LAAS whether or not it is acceptable for them.

thomas-moulard avatar Sep 25 '14 09:09 thomas-moulard

I just found a nice summary of C++11 features and minimum GCC versions: https://gcc.gnu.org/projects/cxx0x.html

I guess the only question is: what is the lowest version of GCC we're supposed to support? The one in 12.04? And then check if the features we could use are well supported with that version (we could even list the features somewhere).

bchretien avatar Sep 25 '14 11:09 bchretien

I don't think there is a good answer to this question.

As long as GCC default behavior is not C++11 in a relatively reasonable proportion of Linux distributions, it won't be a "free move". I.e. users will come and complain because it will break their setup.

So again, I am not against it but my advice is: if we want to make it, let's make it optional first. And let's think of the gain w.r.t to the increase cost of development before.

For me, optional features could be:

  • Move constructors
  • Building functions from lambdas.
  • constexpr when possible

thomas-moulard avatar Sep 26 '14 00:09 thomas-moulard

Some other useful features that we could use:

  • Variadic templates
  • Template aliases

As for the increased cost of development, this can be done incrementally from the moment we make the move (unless there's some very good reason to move as much as possible right away), i.e. new features/fixes can use C++11 features if it is relevant.

Also, I would need to check if the CUDA compiler/parser doesn't explode with the C++11 features we would choose, since C++11 support is experimental and undocumented, and nvcc may include some RobOptim headers.

bchretien avatar Sep 26 '14 08:09 bchretien

We are currently working on some really nice features that would be painful to implement without C++11 (variadic templates saving the day), so this discussion may be revived soon.

bchretien avatar Mar 30 '15 04:03 bchretien