C++: Difference between revisions

No change in size ,  4 November 2019
no edit summary
No edit summary
No edit summary
Line 240: Line 240:
std::numeric_limits<float>::max();
std::numeric_limits<float>::max();
</syntaxhighlight>
</syntaxhighlight>
==Programming Styles==
===Modern C++===
[https://github.com/rigtorp/awesome-modern-cpp List of resources]<br>
Prefer newer std functions available in C++17.<br>
Use shared pointers instead of new and delete.<br>
* Use clang-format.
===Orthodox C++===
[https://gist.github.com/bkaradzic/2e39896bc7d8c34e042b Reference]<br>
Somewhat opposite of modern C++.<br>
Basically only use C++ for its classes. Do everything else C-style.
The main benefit is compatibility with older compilers/libraries and easier understanding for people less familiar with newer C++ features.
*Don't use C++ runtime wrapper for C runtime includes (<cstdio>, <cmath>, etc.), use C runtime instead (<stdio.h>, <math.h>, etc.)
*Don't use stream (<iostream>, <stringstream>, etc.), use printf style functions instead.
*Don't use anything from STL that allocates memory, unless you don't care about memory management.


==STL==
==STL==
Line 289: Line 273:


==Boost==
==Boost==
==Programming Styles==
===Modern C++===
[https://github.com/rigtorp/awesome-modern-cpp List of resources]<br>
Prefer newer std functions available in C++17.<br>
Use shared pointers instead of new and delete.<br>
* Use clang-format.
===Orthodox C++===
[https://gist.github.com/bkaradzic/2e39896bc7d8c34e042b Reference]<br>
Somewhat opposite of modern C++.<br>
Basically only use C++ for its classes. Do everything else C-style.
The main benefit is compatibility with older compilers/libraries and easier understanding for people less familiar with newer C++ features.
*Don't use C++ runtime wrapper for C runtime includes (<cstdio>, <cmath>, etc.), use C runtime instead (<stdio.h>, <math.h>, etc.)
*Don't use stream (<iostream>, <stringstream>, etc.), use printf style functions instead.
*Don't use anything from STL that allocates memory, unless you don't care about memory management.


==Useful Libraries==
==Useful Libraries==