cpp11/notes.rst
2012-05-25 08:17:47 -06:00

101 lines
2.2 KiB
ReStructuredText

=====
C++11
=====
.. rubric:: oh dear, it burns
Intro
=====
- Approved 2011-08-12
- for some time called c++0x
- references:
- primarily the `wikipedia article`_ on c++11
- also `Bjarne's FAQ`_
.. _`wikipedia article`: http://en.wikipedia.org/wiki/C%2B%2B11
.. _`Bjarne's FAQ`: http://www2.research.att.com/~bs/C++0xFAQ.html
initializer lists
=================
- see example with/without -std=c++0x; specifically in this order:
- init.cc
- ilists.cc: c++03
- init_new.cc
- initializer_list<>
- allows constructors to take initializer lists
New Loop Syntax
===============
- example from int, iterator, new syntax
- copy/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
=========
- generalization of std::pair
- #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 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
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
==============