diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-01-13 20:16:25 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-01-14 19:06:40 +0200 |
commit | 9a61a134669c2240100fd1ccadaf974f86fe4655 (patch) | |
tree | 23c21decc6af6f86a2e437e4eb65ee9e4c9a9463 /Documentation/coding-style.rst | |
parent | 055335bf49dbcb8c149bdcd4e96004c68e6b6ece (diff) |
meson.build: Switch to C++14
C++14 is a minor release that doesn't introduce major new concepts or
paradigms compared to C++11, but brings two useful changes for us:
- std::make_unique allows dropping our custom implementation in utils.
- Functions returning constexpr are not assumed to be const anymore,
which is needed to create a standard-conformant span implementation.
All the g++ and clang++ versions we support and test (g++-5 onwards and
clang++6 onwards) support C++14. However, due to a defect in the
original C++14 specification, solved in N4387 ([1]), compilation would
fail on g++-5 due to the use of std::map::emplace() with a non-copyable
value type. It turns out we can easily fix it by switching to the
explicit piecewise emplace() overload.
There is thus really nothing holding back the switch. Let's do it, and
update the coding style accordingly.
[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4387
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'Documentation/coding-style.rst')
-rw-r--r-- | Documentation/coding-style.rst | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/Documentation/coding-style.rst b/Documentation/coding-style.rst index 9939c7b1..bbc1f2fb 100644 --- a/Documentation/coding-style.rst +++ b/Documentation/coding-style.rst @@ -86,22 +86,17 @@ headers, and with double quotes for other libcamera headers. C++ Specific Rules ------------------ -The code shall be implemented in C++03, extended with the following -C++-11-specific features: - -* Initializer lists -* Type inference (auto and decltype) - Type inference shall be used with caution, to avoid drifting towards an - untyped language. -* Range-based for loop -* Lambda functions -* Explicit overrides and final -* Null pointer constant -* General-purpose smart pointers (std::unique_ptr), deprecating std::auto_ptr. +The code shall be implemented in C++14, with the following caveats: + +* Type inference (auto and decltype) shall be used with caution, to avoid + drifting towards an untyped language. +* The explicit, override and final specifiers are to be used where applicable. +* General-purpose smart pointers (std::unique_ptr) deprecate std::auto_ptr. Smart pointers, as well as shared pointers and weak pointers, shall not be overused. -* Variadic class and function templates -* rvalue references, move constructor and move assignment +* Classes are encouraged to define move constructors and assignment operators + where applicable, and generally make use of the features offered by rvalue + references. Object Ownership ~~~~~~~~~~~~~~~~ |