简体   繁体   中英

Using smart pointers on the mbed

Is there a way to use smart pointers on the mbed board , together with the mbed libraries? What compiler is needed?

According to the website, they provide the compiler as an online platform. I can't access it, but assuming it's a somewhat recent version of GCC with C++ enabled, but not so recent that C++11 is an option, you can get smart pointers using TR1.

#include <tr1/memory>

std::tr1::shared_ptr< int > smart = std::make_shared( 5 );

Ah, now I see they support an "export to external toolchain" option. That should give you the freedom to upgrade GCC. I'm not sure what the minimum is for tr1::shared_ptr to be present, but it's likely to be there in any version of GCC 4.x.

If you opt for C++11, it's best to go for the most recent compiler version you can get. You may have to build from source. Be sure to specify the necessary ARM target platform.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM