#include #include #include #include "configuration.h" #include int main(int, char**) { std::fstream fs; fs.open("smolbote.cfg", std::fstream::in); assert(fs.is_open()); { auto value_map = std::make_unique>>({ { "test", std::string("unknown") }, { "integer-1", 20 }, { "integer-2", 30 } }); value_map->read(fs); Configuration::move_global(std::move(value_map)); fs.close(); } { Configuration g; assert(g.value("test") == "value"); assert(g.value("plugins.path") == "/usr/local/lib/smolbote/plugins"); assert(g.value("integer-1") == 20); assert(g.value("integer-2") == 22); } /* { const Configuration conf(std::move(value_map)); assert(conf.value("test") == "value"); assert(conf.value("plugins.path") == "/usr/local/lib/smolbote/plugins"); assert(conf.value("integer-1") == 20); assert(conf.value("integer-2") == 22); } */ // Configuration is now destroyed // This should be a compiler warning //const Configuration c(std::move(value_map)); //assert(c.value("test") == "value"); // This should be a compiler warning and runtime error //assert(value_map.value("test").value() == "value"); return 0; }