Difference between revisions of "C++11"
Jump to navigation
Jump to search
Johanengelen (talk | contribs) |
|||
(24 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
== | == Usage status == | ||
This table lists C++11 features and whether they can be used in Inkscape or not (yet). | |||
Add C++11 features that you would like to use to the table, so that we know what to test for to increase the C++11 "allowance". | Add C++11 features that you would like to use to the table, so that we know what to test for to increase the C++11 "allowance". | ||
See also [[C++17]] | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! Feature | ! Feature !! Can use? !! Comment | ||
! Can use? | |- | ||
! Comment | | std::unique_ptr<> || style="background: lightgreen;" | from 0.93 || Replaces boost::scoped_ptr<> and std::auto_ptr<> | ||
|- | |||
| std::shared_ptr<> || style="background: lightgreen;" | from 0.93 || Replaces boost::shared_ptr<> | |||
|- | |||
| std::unordered_*<> || style="background: lightgreen;" | from 0.93|| Replaces the hack in util/unordered-containers.h | |||
|- | |||
| auto (type inference) || style="background: lightgreen;" | from 0.93 || | |||
|- | |||
| enum class || not yet || Strong enum constants (take the name of the enum, can't be implicitly converted to <code>int</code>) | |||
|- | |||
| range-based for || style="background: lightgreen;" | from 0.93 || Concise for loops with containers (Python alike) | |||
|- | |||
| lambda functions || not yet || In-place definitions for small functions | |||
|- | |- | ||
| | | constructor delegation || not yet || Reduces boilerplate when an object has many constructors | ||
| | |||
| | |||
|- | |- | ||
| | | right angle brackets in templates || not yet || Fixes coding style oddity | ||
| | |||
| | |||
|- | |- | ||
| | | async, futures || not yet || Allows easy multithreading | ||
| | |||
| | |||
|- | |- | ||
| | | std::initializer_list || not yet || Easier container initialization/assignation and implicit constructor calls | ||
| | |||
| | |||
|- | |- | ||
| | | [https://en.cppreference.com/w/cpp/language/constexpr constexpr] || | ? || Additional meanings in C++14/C++17 | ||
| | |||
| | |||
|- | |- | ||
| | | toxic feature of doom || style="background: red;" | NO || Never use this (in case we stumble upon C++11 features that we really don't like) | ||
| style="background: | |||
| | |||
|} | |} | ||
== | == Platform status == | ||
We need to keep coordinated with the section on [[Tracking_Dependencies#Distros|Distro Dependencies]]. | |||
Also see this page: | |||
* http://en.cppreference.com/w/cpp/compiler_support | |||
Note that <code>__cplusplus</code> is always <code>1</code> for GCC 4.6 that is used on Windows. So <code>#if __cplusplus < 201103L</code> or variants does not work to choose between C++03 or C++11 code. | |||
C++11 is well supported by all major compilers (MSVC has only partial support for constexpr). In fact C++14 and C++17 are also well supported by all platforms we support. | |||
Compiler version when feature complete: | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! | ! !! GCC !! Clang !! MSVC | ||
! | |- | ||
! | |C++11 || 4.8 (2014)|| 3.1 (2013) (3.3 for local thread storage and inheriting constructors) || 19 (except C99 preprocessor and constexpr) | ||
! | |||
|- | |- | ||
| | |C++14 || 5 (2015) || 3.4 (2013) || 19 (2017) (19.1 for member initializers) | ||
| | |||
| | |||
| | |||
| | |||
| | |||
|- | |- | ||
| | |C++17 || 7 (2017) || 4 (2017) (5 for constexpr lambda expressions) || 19.14 (2017) | ||
| | |||
| | |||
| | |||
| | |||
| | |||
|- | |- | ||
| | |C++2a || 10* || 10* || 19.22# | ||
| | |||
| | |||
| | |||
| | |||
| | |||
|} | |} | ||
'*' Mostly complete | |||
'#' About half complete |
Latest revision as of 09:11, 17 April 2020
Usage status
This table lists C++11 features and whether they can be used in Inkscape or not (yet). Add C++11 features that you would like to use to the table, so that we know what to test for to increase the C++11 "allowance".
See also C++17
Feature | Can use? | Comment |
---|---|---|
std::unique_ptr<> | from 0.93 | Replaces boost::scoped_ptr<> and std::auto_ptr<> |
std::shared_ptr<> | from 0.93 | Replaces boost::shared_ptr<> |
std::unordered_*<> | from 0.93 | Replaces the hack in util/unordered-containers.h |
auto (type inference) | from 0.93 | |
enum class | not yet | Strong enum constants (take the name of the enum, can't be implicitly converted to int )
|
range-based for | from 0.93 | Concise for loops with containers (Python alike) |
lambda functions | not yet | In-place definitions for small functions |
constructor delegation | not yet | Reduces boilerplate when an object has many constructors |
right angle brackets in templates | not yet | Fixes coding style oddity |
async, futures | not yet | Allows easy multithreading |
std::initializer_list | not yet | Easier container initialization/assignation and implicit constructor calls |
constexpr | ? | Additional meanings in C++14/C++17 |
toxic feature of doom | NO | Never use this (in case we stumble upon C++11 features that we really don't like) |
Platform status
We need to keep coordinated with the section on Distro Dependencies.
Also see this page:
Note that __cplusplus
is always 1
for GCC 4.6 that is used on Windows. So #if __cplusplus < 201103L
or variants does not work to choose between C++03 or C++11 code.
C++11 is well supported by all major compilers (MSVC has only partial support for constexpr). In fact C++14 and C++17 are also well supported by all platforms we support.
Compiler version when feature complete:
GCC | Clang | MSVC | |
---|---|---|---|
C++11 | 4.8 (2014) | 3.1 (2013) (3.3 for local thread storage and inheriting constructors) | 19 (except C99 preprocessor and constexpr) |
C++14 | 5 (2015) | 3.4 (2013) | 19 (2017) (19.1 for member initializers) |
C++17 | 7 (2017) | 4 (2017) (5 for constexpr lambda expressions) | 19.14 (2017) |
C++2a | 10* | 10* | 19.22# |
'*' Mostly complete '#' About half complete