Search

B.2 — Introduction to C++14

What is C++14?

On August 18, 2014, the ISO (International Organization for Standardization) approved a new version of C++, called C++14. Unlike C++11, which added a huge amount of new functionality, C++14 is a comparatively minor update, mainly featuring bug fixes and small improvements.

New improvements in C++14

For your interest, here’s a list of the major improvements that C++14 adds. Note that this list is not comprehensive, but rather intended to highlight some of the key improvements of interest.

  • Aggregate member initialization (4.7 -- Structs)
  • Binary literals (2.8 -- Literals)
  • [[deprecated]] attribute (no tutorial yet)
  • Digit separators (2.8 -- Literals)
  • Function return type deduction (4.8 -- The auto keyword)
  • Generic lambdas and lambda capture expressions (no tutorials yet)
  • Relaxed constexpr functions (no tutorial yet)
  • Variable templates (no tutorial yet)
  • Standard user-defined literals (no tutorial yet)
  • std::make_unique (15.5 -- std::unique_ptr)
B.3 -- Introduction to C++17
Index
B.1 -- Introduction to C++11

24 comments to B.2 — Introduction to C++14

  • Michael

    Thank you for this great site.

    Finally I finished this tutorial after 6 months and I will visit it many more times in the future.

  • warchiefbinar

    I'd like to thank authors for the tutorials. It was a pleasure to read it, I've learnt a lot. Some things are not 100% clear to me but I'm on my way. Once again: thank you very much.

  • Benjamin

    Hi Alex,

    as many already did, also I like to thank you for this tutorial. I attempted to learn C++ already 2 or 3 times over the past 2 decades, but I failed because of my volatile attention span. Your tutorial kept me going until the end. I am sure I will get back here many times and probably even re-read the entire thing.

    A central question for me is: where to go from here on out? You already suggested reading "The C++ Standard Library" by Josuttis. I am going to do that. But I also know I want to dive into GUI programming later. I saw there is a huge amount of libraries available. Do you have any favorites? Or do you probably know a good source that compares these libraries and shows upsides and downsides?

    I read many times in your comments that you are having a hard time extending your tutorial. Still, if there is some time left far far in the future, it might probably be worthwhile to write a brief lesson that offers orientation and outlook to your readers. As I saw in the comments I am not the only one, who has problems to decide what to learn after your tutorial. An outlook might substantially help.

    Thanks again and have a great time!

    • nascardriver

      Hi Benjamin!

      At some point you have to stop learning actively and start using what you learned so far.
      Get a project going. Think of something (You already mentioned GUI) and just try doing it. If you don't know something look it up. You'll find yourself stuck in some situations, that's where you learn new stuff to solve problems.
      Try to find a project that you'll actually have a use of in your every-day-life, this is the hardest part but once you have an idea you're not going to stop until you made it.

      • Benjamin

        That is a true thing! Fortunately, I do not have a lack of possible projects. There is a lot of work-related stuff I could do with C++. I know this kind of pushing the borders of your knowledge by solving new problems. This is a great way to learn. Yet, I'd say reading is not in competition to practical experience, but rather complementary. Even you can't remember everything you read, you will get at least an abstract idea about what tools exist (the big picture). This might help at a later point to quickly find a good solution for your problem at hand.

        I would say that is the reason I am looking for other good tutorials and/or books.

    • Alex

      Thanks for reading the whole thing (and your various feedback), Benjamin. Personally, my favorite GUI libraries are QT, WXWidgets, and SDL -- but I certainly haven't tried them all.

      I agree that a more extended "what next" lesson would be helpful. I'll see if I can find the time to write one.

  • wisdom

    Hey Nascardriver!
    I understand its a whole lot of work, but I don't actually want to build something complex but just a mobile version of the browser via NDK. and as for rendering, I would be using webkit, A HTTP library for fetching external content and some other libraries. but the challenges here is "where should I start from" and "can c++ do all of this natively?"

    • nascardriver

      I took a quick glance at webkit, it seems like a finished browser implementation which you can just build upon, that's boring, I guess you could do it but I don't have any experience with native code on smartphones so I can't help you.

  • Akshay Chavan

    Alex,

    Thank you for this awesome tutorial. Having finished it, I would like to study data structures and algorithms. However, I have a couple of doubts:

    1. Should I use a book that uses C++ as a language in teaching data structures/algorithms OR a language-agnostic book that uses pseudocode?

    2.  At this stage, if I choose a pseudocode book to learn data structures and algorithms, am I capable of reimplementing these in C++ on my own? (With the knowledge gained from this tutorial)

    I want to continue learning C++.

    Thanks

    • nascardriver

      Hi Akshay!
      I'm not a book guy, my 2 cents:

      1.
      I imagine it'll be hard finding a C++ book in a specific topic that uses C++11 onward, most of them will probably still use C or C++98 which is a con for the C++ book.
      You should probably look up which language will be used in your school/university for the course you're interested in. If it's in C++ and you're not feeling confident to solve tasks on your own you could use a C++ book as a cheat sheet, however from my experience, any course you can sign up to without pre-requirements will be laid out for absolute beginners, in that case you'd already have a big advantage just from knowing what you've learned here.

      2.
      Let's see.
      Given the following data, write a program that stores the data in suitable containers and uses merge sort ( http://www.algorithmist.com/index.php/Merge_sort ) to sort the vehicles by speed.
      Subaru 90km/h
      Mustang 300 km/h
      Volkswagen 123km/h
      Lexus 20km/h
      Maserati 210km/h
      Peugeot 150km/h
      Camaro 130km/h
      Charger 90km/h
      Skoda 40km/h
      Jeep 130km/h
      There is a also C++ implementation on the linked site, you don't need to make it that generic.
      If you don't like merge sort you can use quick sort ( http://www.algorithmist.com/index.php/Quicksort )

      • Akshay Chavan

        Thank you for taking the time to advise me nascardriver! I really appreciate it. The reason why I asked this question was that a lot of people seem to advise learning data structures and algorithms INDEPENDENT of a programming language, and not rely too much on the standard library of a language. But on the other hand, in C++, one is told not to reinvent the wheel, that is, to use the STL where one can. So that left me confused.

        BTW I am self-teaching myself C++ (no CS degree). I want to become a really good C++ programmer.

        Thanks for the help!

        • nascardriver

          "use the STL where one can"
          That's correct, but it's good to know how to STL is doing certain things.

          "learning data structures and algorithms INDEPENDENT of a programming language"
          Once you've written (not copied) an algorithm in a certain language you'll usually know how to do it by hand. So which language you learn the algorithm in doesn't matter.

        • Alex

          I agree with both statements. Learn data structures and algorithms as general concepts. Implement them yourself in your favorite language. You will learn how they work, and their various strengths and weaknesses. And the programming practice will help you get better at implementing non-trivial, reusable code.

          Then throw your versions out and use the standard library versions. 🙂 Which you will be able to now do effectively, because you'll understand which classes you should use for what kind of projects.

          • Akshay Chavan

            That sounds like a good idea, Alex. This way I will get to code DS&A by hand, and also learn how to implement them by using the standard library. Thank you for the advice!

  • wisdom

    Firstly I wanna thank you for this awesome tutorial, it has really helped me a lot. Now my question is. Can I build a "not too complex" web browser with C++? if yes, how do I go about after taking all of this lesson.
    Thanks in advance for your reply

    • nascardriver

      Hi wisdom!
      You can do anything in C++. A webbrowser is a really tough task, you'll need threading, networking, parsing, rendering, user io, etc.
      It's not like .net where you can just drag 'n drop a webbrowser element into a window and be done with it. If you want something in C++ you'll have to do it yourself or use someone else's code.

    • Alex

      I agree with nascardriver, building a web browser is not for the faint of heart. They are surprisingly complex. If you even wanted to try to do something like this, I'd advise two things:
      1) Get a library that does internet network calls (so you can call a URL and get the raw web page back).
      2) Get a visual framework (e.g. qt, wxwidgets, etc...) so you can create graphical windows and use standard widgets.

      That will at least get you set up and headed in the right direction.

  • John Wayne

    Thanks for the tutorials mate, can you tell me where should I head next after completing this lessons ?
    I want continue learning C++.

    • Alex

      There are a few things you can do next:
      1) Learn more about algorithms and data structures (useful for any language)
      2) Learn more about the C++ standard library (this somewhat overlaps with #1)
      3) Learn a C++ UI toolkit so you can make graphical applications

      As for specific tutorials or books to do these things, I don't have any good recommendations.

  • garry ehrlich

    Hi Alex- I noticed that there are a lot of (no tutorials yet) sprinkled throughout the lists of improvements.
    Taking the 'yet' to mean that you intend to write these tutorials in the future, it would be really cool if
    you could somehow give us a heads-up when you produce one.

    Kudos for the splendid ones that already exist.

    garrye

    • Alex

      I would like to write them someday, but it's not clear yet when I'll be able to.

      Whenever I update one of these, I'll update the front page link to this article with an updated date. So check the front page periodically. There are also chrome plugins that can help with this (e.g. visualping). I'm not sure whether the ads will throw them off, but you might give it a whirl.

  • John

    just a suggestion, would like to see something on threads and events and moving data between threads.  thanks

Leave a Comment

Put all code inside code tags: [code]your code here[/code]