[Error] main.cpp@7,34: no matching conversion for functional-style cast from 'int *' to 'std::shared_ptr<int []>' [Error] main.cpp@8,8: type 'std::shared_ptr<int []>' does not provide a subscript operator [ERROR] .\main.cpp:7:34: error: no matching conversion for functional-style cast from 'int *' to 'std::shared_ptr<int []>' std::shared_ptr<int[]> arr = std::shared_ptr<int[]>(new int[20]);
In the mbed library, Tools/profiles/debug.json, I can see the following:
Sorry for the late reply, I had to seek some clarification with another team. shared_ptr to array isn’t supported until C++17, which Arm Compiler 6 only provides as a COMMUNITY feature currently: Documentation – Arm Developer
But passing std=c++17 should allow your code above to compile.
I’m not sure why GCC appears to be backwards compatible with this.
Thanks - that is really useful to know. In fact, having read the link you provide, I am inclined to add
-Wpedantic to make it clearer to students. In this context, risk management is more important than new language features for sure!
Good question. Maybe a better expression is “defensive coding”.
If developing software to run unsupervised 24/7, maybe sticking to the language version Arm recommend rather than leaping for newer and greater. Presumably mbed os has a QA process, and this is done using c++14.