Arm Mbed OS support forum

Difference between mstd::span and mbed::Span

Mbed has both mstd::span and mbed::Span – what is the difference and when use one over the other? Will mbed::Span be replaced by mstd::span in the future?

From my understanding, mstd::span is an std-like implementation of std::span that will be available in C++20. Is that correct? Is it ready to be used?

Thanks for your help!

cc @vcoubard :slight_smile:

Yes it should be ready to be used and it will supersede mbed::Span. See the discussion here: Add std::span implementation for cxxsupport by marcemmers · Pull Request #13881 · ARMmbed/mbed-os · GitHub .

1 Like

Ah yes I remember! Thanks a lot! :slight_smile:

and again time to ask when the upgrade to C++17 will be made. The show stopping ‘register’ keyword should be removed now with the updated HAL for STM targets.

C++17? Live a little! Let’s do C++20!

Point made though. We’ve been using C++17 for a few months, and apart from making our code base better, we have had no issues.

I’m waiting for the custom toolchain file support for CLI 2 to jump onto the C++17 wagon. Is it currently possible to do it without doing upstream mbed changes?

What do you mean?

How do we change the C++ version (or other compiler flags for that matter) with CLI 2?

I’d say in the main CMakeLists.txt, no?

# Set C/C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS TRUE)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS TRUE)

Probably a good idea :smile: I’m just not aware of some of the best practices when it comes to CMake. I’ll try it out, thanks!