Most people think that they know C++ which is used in production level as they are taught C++ in their syllabus of their university/college. But they mostly do not know what standard of C++ they are taught. They are taught C++ 89 i.e. CFront 2.0. Students are told to use Turbo C++ as IDE to learn C++ in university because it is or was a great IDE in it's age. As the academic syllabus takes a lot of time to change and people don't know that it is outdated mostly trend to learn old coding styles and deprecated features.
What is Modern C++?
Modern C++ stands for C++ that is based on C++11, C++14, and C++17 C++20 and future versions.
With C++11 we had a revolution. That revolutions became with C++14 and will become with C++17 to an evolution. An overview on the time line of C++ features which makes my point clear.
Modern C++ not only enhances the usability of the C++ itself, but the modification of the auto
keyword semantics gives more confidence in manipulating extremely complex template types. At the same time, a lot of enhancements have been made to the language at runtime. The emergence of Lambda expressions has made C++ have the "closure" feature of "anonymous functions", which is almost in modern programming languages (such as Python/Swift/.. It has become commonplace, and the emergence of rvalue
references has solved the problem of temporary object efficiency that C++ has long been criticized for.
Deprecated Features
- The string literal constant is no longer allowed to be assigned to a
char *
. If you need to assign and initialize achar *
with a string literal constant, you should useconst char *
orauto
.
char *str = "hello world!"; // A deprecation warning will appear
C++98
exception description
,unexpected_handler
,set_unexpected()
and other related features are deprecated and should usenoexcept
.auto_ptr
is deprecated andunique_ptr
should be used.register
keyword is deprecated and can be used but no longer has any practical meaning.bool
can no longer be incrementedIf a class has a
destructor
, the properties for which it generates copy constructors and copy assignment operators are deprecated.C language style type conversion is deprecated (ie using (convert_type)) before variables, and
static_cast
,reinterpret_cast
,const_cast
should be used for type conversion.In particular, some of the C standard libraries that can be used are now deprecated in the latest C++ standard, such as
<ccomplex>
,<cstdalign>
,<cstdbool>
and<ctgmath>
.Many more that I cannot remember.
Resources of learning Modern C++
- AwesomePerfCpp
- Modern C++ Book
- Best Practices
- Awesome Modern C++
- Modern C++ Tutorials
- Iso C++
- 30 Seconds of C++
- C++ Preference
List of Posts made by me
Modern C++ : `and`, `or` and `not` as Boolean Operators
Swastik Baranwal ・ Dec 26 '19
Modern C++: enum class|struct
Swastik Baranwal ・ Apr 9 '20
Github
All the code used in my articles are available on Delta456/modern-cpp-series.
Delta456 / modern_cpp_series
Code for my Modern C++ Articles
Modern C++ Series
Code for my Modern C++ Article Series.
Top comments (5)
I chuckled a little at
bool can no longer be incremented
!Part of me really wants to know the backstory to that and why (if purposefully) that was ever possible!
hhh, I did too and was wondering if anyone posted a comment on that. And yes I was not alone :D
Just to say, that Turbo C was the ugliest IDE and to be honest I dislike it. I use gcc and g++ to compile code what kind of IDE or Environment do you prefer?
g++ and VSCode for me
Heads up! I have updated the main post and I will continue my series when C++ 20 is out because there are gonna be many new features and major changes. Hope you are looking forward to it!