#cpp #cplusplus #education #teaching #EduSky
Moderated by @smurthys.bsky.social
Compilation of possible implementations from cppreference. Hope seeing it all together at once helps appreciate the behind-the-scenes.
PS: read the code bottom to top; usable with no includes
sigcpp.godbolt.org/z/nx6Y3sfvo
#cpp #eduSky
Compilation of possible implementations from cppreference. Hope seeing it all together at once helps appreciate the behind-the-scenes.
PS: read the code bottom to top; usable with no includes
sigcpp.godbolt.org/z/nx6Y3sfvo
#cpp #eduSky
E.g., S1() involves 4 ctors; but S2() involves only 2.
sigcpp.godbolt.org/z/4e93ddd5x
#cpp #eduSky
E.g., S1() involves 4 ctors; but S2() involves only 2.
sigcpp.godbolt.org/z/4e93ddd5x
#cpp #eduSky
The syntax permits seemingly odd type qualifiers but the quals actually apply to the var not the type (2).
sigcpp.godbolt.org/z/fvY64MMqT #cpp
The syntax permits seemingly odd type qualifiers but the quals actually apply to the var not the type (2).
sigcpp.godbolt.org/z/fvY64MMqT #cpp
Bottomline, instead of C-style cast, use an appropriate C++ cast such as `static_cast` and `dynamic_cast` depending on the situation.
www.youtube.com/watch?v=SmlL...
#cpp #cplusplus #programming #video
Bottomline, instead of C-style cast, use an appropriate C++ cast such as `static_cast` and `dynamic_cast` depending on the situation.
www.youtube.com/watch?v=SmlL...
#cpp #cplusplus #programming #video
You don't always get this benefit but strive.
E.g.: sigcpp.godbolt.org/z/sjd5vWrPn
(Avoid "naked new" but another time)
#cpp #cPlusPlus #programming
You don't always get this benefit but strive.
E.g.: sigcpp.godbolt.org/z/sjd5vWrPn
(Avoid "naked new" but another time)
#cpp #cPlusPlus #programming
1. Copy source and reverse the copy
or
2. Create a new string inited from reverse iterators on source
Approach 2 can be faster, and the new string can even be const.
sigcpp.godbolt.org/z/9coKnYTTs
#cpp #cplusplus #programming
1. Copy source and reverse the copy
or
2. Create a new string inited from reverse iterators on source
Approach 2 can be faster, and the new string can even be const.
sigcpp.godbolt.org/z/9coKnYTTs
#cpp #cplusplus #programming
PS: std::to_integer converts only from std::byte and the integer type must be explicit.
https://sigcpp.godbolt.org/z/4Waxaojrz
#cpp #cplusplus
PS: std::to_integer converts only from std::byte and the integer type must be explicit.
https://sigcpp.godbolt.org/z/4Waxaojrz
#cpp #cplusplus