cpp11/notes.rst

81 lines
1.6 KiB
ReStructuredText
Raw Normal View History

2012-05-05 08:36:42 -07:00
=====
C++11
=====
.. rubric:: oh dear, it burns
- Approved 2011-08-12
- for some time called c++0x
- references: primarily the `wikipedia article`_ on c++11
.. _`wikipedia article`: http://en.wikipedia.org/wiki/C%2B%2B11
constexpr
=========
- see example with/without -std=c++0x
- see wiki for limitations
- constructors of user-defined types can be declared constexpr
initializer lists
=================
- see example with/without -std=c++0x
- initializer_list<>
- constructed, copied, only by ref
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
=========
- #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
=================================
- this is where the burning starts ...
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
==============