0

Is it a way to use constexpr with yaml-cpp ? I tried :

constexpr YAML::Node sample = YAML::LoadFile("sample.yaml");

but it seems that's not possible with the actual implementation of yaml ?

max66
  • 65,235
  • 10
  • 71
  • 111
Kafka
  • 720
  • 6
  • 21
  • 2
    I doubt it's going to be possible with *any* implementation of YAML. `constexpr` is used to define compile-time constants, or expressions able to produce compile-time constants. There is no way how the result of `YAML::LoadFile(…)` might be known at compilation time. – ach Feb 27 '17 at 07:17
  • If you do have a constexpr string, and if `YAML::Load` is a constexpr function, you could do `constexpr YAML::Node sample = YAML::Load("[1, 2, 3]");` – Caleth Feb 27 '17 at 11:25
  • the idea was to use yaml data (from a file *.yml) in a template expression, in order to get some optimisations, but it's probably not possible. – Kafka Feb 27 '17 at 14:22

0 Answers0