element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Software
  • Products
  • Dev Tools
  • Software
  • More
  • Cancel
Software
Forum anyone investigating, learning or using the recent c++ or STL functionality?
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Software to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 13 replies
  • Subscribers 28 subscribers
  • Views 2328 views
  • Users 0 members are here
  • c++
Related

anyone investigating, learning or using the recent c++ or STL functionality?

Jan Cumps
Jan Cumps over 2 years ago

What the title says Slight smile.

Since autumn 2021, I'm learning the c++ 20 language evolutions. Almost finished. Is anyone else into this?

  • Sign in to reply
  • Cancel

Top Replies

  • Jan Cumps
    Jan Cumps over 2 years ago in reply to shabaz +1
    I think that STL has been a gem from the start. With warts. The implementation has been lean from the start; better containers, iterators and reuse, than what most of us would invent. It was a kicker…
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to shabaz +1
    shabaz said: Currently I'm keen to learn CMake a bit more, I started a tutorial, and need to get back to it sometime. That will be valuable at any time. Regardless if you do c, c++, whatever compiler…
  • neuromodulator
    neuromodulator over 2 years ago +1
    If STL can do the job, I've always preferred it over other libs (like boost, or native OS lib). But I haven't stayed up to date with the latest additions of the language. C++ gets on every release more…
  • shabaz
    shabaz over 2 years ago

    I'm not using it, but I still have interest and I enjoy seeing what can be done with it. 

    Any pointer on the evolutions would be interesting to check out.

    I have used old STL, although usually dragged reluctantly into it, because I don't use it often enough any more. It's extremely powerful of course but used to be quite difficult to debug from cryptic error messages, maybe that is improved now? No idea. I got there over time though, through lots of familiarity in recognizing the same error messages a few times. 

    Also, some users may never experience STL since it may be in the libraries they use, but not in the end application code, and not see what a great problem-solver it can be.

     Currently I'm keen to learn CMake a bit more, I started a tutorial, and need to get back to it sometime.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to shabaz

    I think that STL has been a gem from the start. With warts. The implementation has been lean from the start; better containers, iterators and reuse, than what most of us would invent.

    It was a kicker for the template part of the c++ language. The first time that a lot of people could profit from it - even if they didn't understand the abstractions.
    And it had a lot of issues. Some because of naïve assumptions, some because the language itself had restrictions, some because they didn't know how it would be used yet.

    I think that the c++20 iteration is well worth reviewing, because it's a mature version, that dealt with many of the things (including funny error messages). They kept everything that was valuable from the initial design. Several of the later additions became part of the standard. But they also kicked out some of the later additions that were weak.

    This version c++20, I think, is a sound release. Learning it will also introduce the language improvements that have been happening along the way.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to shabaz
    shabaz said:
    Currently I'm keen to learn CMake a bit more, I started a tutorial, and need to get back to it sometime.

    That will be valuable at any time. Regardless if you do c, c++, whatever compiler or version, … Being able to set up or use a good build and dependency environment is an asset. Great skill for a single developer. Essential for a mature team.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz over 2 years ago in reply to Jan Cumps

    Totally agree! And without this knowlege, one is forever restricting their code to one or a few files, and all the unmaintainability of that. (Sometimes it's reasonable to do so but that's infrequent). 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz over 2 years ago in reply to Jan Cumps

    I recall finding some bugs on occasion with STL, but they could have been compiler bugs. I think on my next software code in C/C++, I'll aim to do incrementally more and more C++ each time, and start using STL again from time to time too. It's a brilliant problem-solver.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • DAB
    DAB over 2 years ago

    It does take a while to learn a new language and really explore its capabilities.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • neuromodulator
    neuromodulator over 2 years ago

    If STL can do the job, I've always preferred it over other libs (like boost, or native OS lib). But I haven't stayed up to date with the latest additions of the language.

    C++ gets on every release more and more complex. More rules, more exceptional cases and newer complex concepts. Templates were right from the start a little confusing, and they have continued to add more features to it. I just can't imagine how much more complex it has all become. It looks as if they wanted to make the language so complex that nobody would ever be able to fully understand it.

    Some will tell you that you don't have to use or learn every features, and I agree, but only if you are the only one writing code. The moment you are working with other's people code you have to learn all these new features (unless they are not used).

    A few weeks ago I began learning Rust after seeing more and more support from companies and people, and so far I've liked it quite a bit. I'll probably prefer it over C++ every time unless its not an alternative. Rust feels like a modern language with many new and interesting features that I've never seen in other languages, that make life much easier. 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to neuromodulator

    attention: critique Slight smile and comment:

    neuromodulator said:
    I've always preferred it over other libs (like boost, or native OS lib).

    Some boost libs made it to standard. I think it's a great cradle for ideas.

    neuromodulator said:
    C++ gets on every release more and more complex.

    It does not. They simplify with each release, as well as growing. People use new options, learn from it, and critique. The committee takes the learnings into account.

    neuromodulator said:
    Templates were right from the start a little confusing, and they have continued to add more features to it. I just can't imagine how much more complex it has all become. It looks as if they wanted to make the language so complex that nobody would ever be able to fully understand it.

    They are new if you come from functional programming. They make your life easier if you're building object oriented reusable objects. Templates aren't complex. They are  thing to learn if you want to write generic libraries. They are a non-event if you want to use those libraries.

    neuromodulator said:
    Some will tell you that you don't have to use or learn every features, and I agree, but only if you are the only one writing code. The moment you are working with other's people code you have to learn all these new features (unless they are not used).

    That has been true since assembler introduced macros.

    neuromodulator said:
    A few weeks ago I began learning Rust after seeing more and more support from companies and people, and so far I've liked it quite a bit. I'll probably prefer it over C++ every time unless its not an alternative.

    We all have that, don't we? A preferred language that feels like home. Something that's a free thing when doing a hobby. 
    In this post, I'm looking for thoughts on c++ and STL. There are going to be a wealth of good (better) contenders out there. They won't add to the discussion. There will be Python post here too. If they talk about a different mechanism in the language related to the topic, that may help. Else it's just the internet being the internet.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 2 years ago

    A Pico OO program that uses a class to talk to an m25xxx SPI flash eeprom IC, and stl containers to return bytes.
    The program uses auto to iterate over the bytes:

    image

    class declaration:

    class m25 {
    public:
      m25(spi_inst_t * spi, uint sclk, uint mosi, uint miso, uint ncs) : 
        spi(spi), sclk(sclk), mosi(mosi), miso(miso), ncs(ncs) {}
      ~m25() {}
      void init();
      
      std::vector<uint8_t> rdid();
      std::vector<uint8_t> rdsr();
    
    private:
      enum commands : uint8_t { 
        RDID = 0x9F,
        RDSR = 0x05 };
      spi_inst_t * spi;
      uint sclk, mosi, miso, ncs;
    
    // ...

    implementation:

    // ...
    std::vector<uint8_t> m25::rdid() {
        uint8_t buf[3];
        // command
        uint8_t cmdbuf[] = {
                RDID,
        };
        setDataBits(8);
        select();
        spi_write_blocking(spi, cmdbuf, 1);
        spi_read_blocking(spi, 0, buf, 1); // Manufacturer Identification
        spi_read_blocking(spi, 0, buf + sizeof buf[0], 2); // Device Identification (Memory Type || Memory Capacity)
        deselect();
        return std::vector<uint8_t> (buf, buf + (sizeof buf/sizeof buf[0]));
    }
    
    std::vector<uint8_t> m25::rdsr() {
        uint8_t retval = 0U;
        uint8_t buf[1];
        // command
        uint8_t cmdbuf[] = {
                RDSR,
        };
        this->setDataBits(8);
        this->select();
        spi_write_blocking(spi, cmdbuf, 1);
        spi_read_blocking(spi, 0, buf, 1); // Read Status Register
        this->deselect();
        return std::vector<uint8_t> (buf, buf + (sizeof buf/sizeof buf[0]));
    }
    
    // ...

    Several things look completely different than C, others are exactly the same. The parts that are the same, are usually the places where I talk to the RP2040 C SDK.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 2 years ago

    side story: a year ago, I had to install specific toolchains to be able to test part of the standard c++20 features. And could run it on a Windows laptop and a decent SBC, like the Pi.

    Now, I can just use the default Raspberry Pico C toolchain, and then can compile & debug c++20 OO software for the RP2040 controller. Things move.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube