On 16 Jan 2016 at 15:06, Shangtong Zhang wrote:
// At global scope, allocates no memory whatsoever static const constexpr static_map
map { { 5, "apple" }, { 8, "pear" }, { 0, "banana" }, ... }; // Works map[5]="orange"; assert(map[5] && !strcmp(map[5], "orange"); I have difficulty understanding this, As variable map is const and constexpr, how can map[5]=“orange” work? I don’t know how to implement this, where to store the “orange”. Could anyone help me?
Good catch. You are right that if it is const, it cannot be modified without a compiler error. If it is constexpr, it can only be modified in a constexpr evaluation context, and otherwise not. I'll fix the project idea description before I announce the call for GSoC project ideas which will be probably Monday. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/