2012-05-05 08:36:42 -07:00
|
|
|
=====
|
|
|
|
C++11
|
|
|
|
=====
|
|
|
|
|
|
|
|
.. rubric:: oh dear, it burns
|
|
|
|
|
2012-05-25 07:17:47 -07:00
|
|
|
Intro
|
|
|
|
=====
|
|
|
|
|
2012-05-05 08:36:42 -07:00
|
|
|
- Approved 2011-08-12
|
|
|
|
- for some time called c++0x
|
2012-05-25 07:17:47 -07:00
|
|
|
- references:
|
|
|
|
- primarily the `wikipedia article`_ on c++11
|
|
|
|
- also `Bjarne's FAQ`_
|
2012-05-05 08:36:42 -07:00
|
|
|
|
|
|
|
.. _`wikipedia article`: http://en.wikipedia.org/wiki/C%2B%2B11
|
2012-05-25 07:17:47 -07:00
|
|
|
.. _`Bjarne's FAQ`: http://www2.research.att.com/~bs/C++0xFAQ.html
|
2012-05-05 08:36:42 -07:00
|
|
|
|
|
|
|
|
|
|
|
initializer lists
|
|
|
|
=================
|
|
|
|
|
2012-05-25 07:17:47 -07:00
|
|
|
- see example with/without -std=c++0x; specifically in this order:
|
|
|
|
- init.cc
|
|
|
|
- ilists.cc: c++03
|
|
|
|
- init_new.cc
|
2012-05-05 08:36:42 -07:00
|
|
|
- initializer_list<>
|
2012-05-25 07:17:47 -07:00
|
|
|
- allows constructors to take initializer lists
|
|
|
|
|
|
|
|
New Loop Syntax
|
|
|
|
===============
|
|
|
|
- example from int, iterator, new syntax
|
|
|
|
- copy/ref
|
2012-05-05 08:36:42 -07:00
|
|
|
|
|
|
|
type inference
|
|
|
|
==============
|
|
|
|
|
|
|
|
- auto keyword
|
|
|
|
- decltype
|
|
|
|
|
|
|
|
new string literals
|
|
|
|
===================
|
|
|
|
|
|
|
|
- u8"I'm a UTF-8 string."
|
|
|
|
- u"This is a UTF-16 string."
|
|
|
|
- U"This is a UTF-32 string."
|
|
|
|
|
|
|
|
tuple fun
|
|
|
|
=========
|
|
|
|
|
2012-05-25 07:17:47 -07:00
|
|
|
- generalization of std::pair
|
2012-05-05 08:36:42 -07:00
|
|
|
- #include <tuple>
|
|
|
|
- make_tuple
|
|
|
|
- tie
|
|
|
|
|
|
|
|
lambdas
|
|
|
|
=======
|
|
|
|
|
|
|
|
- see `c++11 anonymous funcs`_
|
|
|
|
- [capture](arguments) -> return-type {body}
|
|
|
|
- capture:
|
|
|
|
- [] capture nothing
|
|
|
|
- [x, &y] x by value, y by reference
|
|
|
|
- [&] any external variable captured by ref
|
|
|
|
- [=] any external variable captured by val
|
|
|
|
- [&, x] x by val, everything else by ref
|
|
|
|
- [=, &x] x by ref, everything else by val
|
|
|
|
|
|
|
|
.. _`c++11 anonymous funcs`: http://en.wikipedia.org/wiki/Anonymous_function#C.2B.2B
|
|
|
|
|
|
|
|
regular expressions and threading
|
|
|
|
=================================
|
|
|
|
|
2012-05-25 07:17:47 -07:00
|
|
|
- this is where the burning starts to set in ...
|
|
|
|
- compile with gcc to see how awesome that is
|
|
|
|
- compile with clang
|
|
|
|
- instructions on building this found `here`_
|
|
|
|
|
|
|
|
.. _`here`: http://solarianprogrammer.com/2011/10/16/llvm-clang-libc-linux/
|
|
|
|
|
|
|
|
constexpr
|
|
|
|
=========
|
|
|
|
|
|
|
|
- see example with/without -std=c++0x
|
|
|
|
- see wiki for limitations
|
|
|
|
- constructors of user-defined types can be declared constexpr
|
2012-05-05 08:36:42 -07:00
|
|
|
|
|
|
|
rvalue
|
|
|
|
=======
|
|
|
|
|
|
|
|
- pass-by-value is deep-copy (usually)
|
|
|
|
- c++11 adds notion of "move constructor"
|
|
|
|
- takes the rvalue ref's stuff and nullifies the rvalue
|
|
|
|
- 'safe and invisible' (because it's null, memory is not del'd when it goes
|
|
|
|
out of scope)
|
|
|
|
- rvalue is automatic when using stuff with "move constructor"
|
|
|
|
- std::move<T>()
|
|
|
|
|
|
|
|
Smart Pointers
|
|
|
|
==============
|