C++ 11 in your project
by hub, Wednesday 12 June 2013 at 01:24 :: C++ :: #838 :: rss
C++ 11 is now available in both gcc
and clang
. That mean it is really available where it matters.
Using C++ 11 in your project (with autoconf).
First if you use autoconf, you have to detect it. The autoconf archive has a macro. Download the .m4 definition and put it in your m4
directory in your project.
In the configure.ac
, add the following line:
AX_CXX_COMPILE_STDCXX_11(noext,mandatory)
Make sure it appears after
AC_GNU_SOURCE
This is will make configure detect C++11 support, without GNU extension (I tend to avoid these in general) and fail if it doesn't exist. If you prefer to make it optional, read the above documentation that has more details.
The interesting features
I'm interested in several features from C++11.
auto
to automatically deduct the type where it can. Ever gotten annoyed by the long type name for iterators of containers? Just useauto
instead.- Lambda: now you can write lambda functions like in Python or JavaScript. This is overly convenient when you iterate over containers or use
std::for_each()
. - The smart pointers: I was using the one from Boost, then the one from
std::tr1::
. Just replace withstd::
std::bind
andstd::function
to replace Boost own versions.
There are more, I'll talk about it when I get to look at them.
Comments
Wednesday 12 June 2013 12:07, by squib :: #
Post a comment
Comments are closed.