1,852
edits
m (Add new recommendation on references) |
(→C++ features: Overhaul text.) |
||
Line 182: | Line 182: | ||
, consider using 'const' references. This helps avoid overflowing the finite stack capacity | , consider using 'const' references. This helps avoid overflowing the finite stack capacity | ||
of a program while still ensuring that read-only access is enforced. | of a program while still ensuring that read-only access is enforced. | ||
=== std::string === | === std::string === | ||
When an empty string is required, use "", rather than creating an empty | When an empty string is required, use <code>""</code>, rather than creating an empty | ||
string object with std::string (). | string object with <code>std::string ()</code>. | ||
=== auto === | === auto === | ||
Line 207: | Line 201: | ||
Always use one of the four C++ long style casting forms ({{codeline|static_cast}}, {{codeline|dynamic_cast}}, {{codeline|reinterpret_cast}}, {{codeline|const_cast}}) rather than C-style forms (type cast {{codeline|(new_type) variable}} or the function form {{codeline|new_type (variable)}}). | Always use one of the four C++ long style casting forms ({{codeline|static_cast}}, {{codeline|dynamic_cast}}, {{codeline|reinterpret_cast}}, {{codeline|const_cast}}) rather than C-style forms (type cast {{codeline|(new_type) variable}} or the function form {{codeline|new_type (variable)}}). | ||
=== C++14 === | === C++11 features === | ||
A C++11 compatible compiler is required for [[Building | building Octave]]. Please make use of all C++11 features. | |||
=== C++14, C++17, C++20 features === | |||
Try to avoid C++14, C++17, or C++20 features. Octave is widely used in very old systems and we want them to be able to use up to date versions of Octave. Building a recent compiler in such systems is not a trivial task so the limitation must happen | |||
want them to be able to use up to date versions of Octave. Building a recent | |||
compiler in such systems is not a trivial task so the limitation must happen | |||
in Octave. | in Octave. | ||
If the implementation using a C++14, C++17, or C++20 feature is very beneficial. Make it optional via <code>configure</code> feature detection or also implement an alternative code in the absence of said feature. In any case, please get in contact with the Octave maintainers on [https://octave.discourse.group/c/maintainers/7 Discourse]. | |||
alternative code in the absence of said feature. In | |||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> |