プログラムのディレクトリ構造を定数文字列の構造として保存したいのですが、C++ では直感的な方法でそれを行うことができません。
したがって、これは機能しません:
struct DirStructure {
static const std::string entities = "./entities";
static const std::string scripts = "./scripts";
}
これもありません:
struct DirStructure {
static const std::string entities() const = { return "./entities"; }
static const std::string scripts() const { return "./scripts"; }
}
(実際には const なしで実行されますが、私はあまり好きではありません)。
これは機能します:
namespace DirStructure {
static const std::string entities = "./entities";
static const std::string scripts = "./scripts";
}
しかし、それには他にもいくつかの問題があります。
そのような問題に対処する標準的な方法は何ですか (私がむしろ避けたいと仮定して#define MY_SCRIPTS_DIR_PATH "./scripts"
)?