So in javascript we can access the member of any object by just using []. For example:
let obj = { foo : 'bar'};
let accessedField = obj["foo"];
obj["foo"] = "something"
How can I access a member of a namespace without knowing the name of the member beforehand like if I get it from somewhere else as input, a string/char* for example. Not necessarily looking for the operator[]
implementation.
namespace Foo {
int bar = 2;
}
Foo["bar"] = 3;
The reason is so I can dynamically access items and I don't want too use std::maps.
**EDIT: Just to clarify not necessarily the [] operator but any way to dynamically access a member of a namespace without knowing it beforehand.