mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
Use c-strings to constant initialize token array
Since `std::string` has to be dynamically constructed and destructed, it could be accessed before initialization or after destruction in a multithreaded context. By using constant c-strings instead, we guarantee that the array will be valid for the whole lifetime of the program. The use of `constexpr` also enforces this requirement. I have run clang-format on the file to format my changes according to CONTRIBUTING.md.
This commit is contained in:

committed by
Jesse Beder

parent
b95aa146ec
commit
9f7babc3ff
@@ -13,7 +13,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace YAML {
|
||||
const std::string TokenNames[] = {
|
||||
constexpr const char* TokenNames[] = {
|
||||
"DIRECTIVE", "DOC_START", "DOC_END", "BLOCK_SEQ_START",
|
||||
"BLOCK_MAP_START", "BLOCK_SEQ_END", "BLOCK_MAP_END", "BLOCK_ENTRY",
|
||||
"FLOW_SEQ_START", "FLOW_MAP_START", "FLOW_SEQ_END", "FLOW_MAP_END",
|
||||
|
Reference in New Issue
Block a user