C++ style guide: Difference between revisions

m (Reverted edits by Diana Trujillo (talk) to last revision by Rik)
Tag: Rollback
Line 369: Line 369:
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++11 features ===
=== C++17 features ===


A C++11 compatible compiler is required for [[Building | building Octave]].  Please make use of all C++11 features.
A C++17 compatible compiler is required for [[Building | building Octave]].  Please make use of all C++17 features.


=== C++14, C++17, C++20 features ===
=== C++20, C++23, C++26 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
Try to avoid C++20, C++23, and C++26 features.  Octave is widely built and used on older 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 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].
If the implementation using a C++20, C++23, or C++26 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].


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">