samedi 26 janvier 2019

C++11: Initialize constexpr char array with another constexpr char array

I would like to initialize constexpr char[] member with another constexpr char [] member. Is it possible to do in C++11 or above?

#include <iostream>

struct Base {
 static constexpr char ValueOne[] = "One";
 static constexpr char ValueTwo[] = "Two";
};

template <typename T>
struct ValueOneHolder {
  static constexpr char Value[] = T::ValueOne; // << How can one initialize this?
};

int main() {
  std::cout << ValueOneHolder<Base>::Value << std::endl;
  return 0;
}

Aucun commentaire:

Enregistrer un commentaire