c++20

What is a “span” and when should I use one?

喜夏-厌秋 提交于 2019-11-26 03:15:36
问题 Recently I\'ve gotten suggestions to use span<T> \'s in my code, or have seen some answers here on the site which use span \'s - supposedly some kind of container. But - I can\'t find anything like that in the C++ standard library. So what is this mysterious span<T> , and why (or when) is it a good idea to use it if it\'s non-standard? 回答1: What is it? A span<T> is: A very lightweight abstraction of a contiguous sequence of values of type T somewhere in memory. Basically a struct { T * ptr;

enum to string in modern C++11 / C++14 / C++17 and future C++20

人盡茶涼 提交于 2019-11-26 00:39:00
问题 Contrary to all other similar questions, this question is about using the new C++ features. 2008 c Is there a simple way to convert C++ enum to string? 2008 c Easy way to use variables of enum types as string in C? 2008 c++ How to easily map c++ enums to strings 2008 c++ Making something both a C identifier and a string? 2008 c++ Is there a simple script to convert C++ enum to string? 2009 c++ How to use enums as flags in C++? 2011 c++ How to convert an enum type variable to a string? 2011 c+