fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <tuple>
  4.  
  5. enum ConfigEntry : unsigned int {
  6. PLAYER_NAME = 0,
  7. CONNECTION_TIMEOUT
  8. };
  9.  
  10. struct ResourceManager {
  11. template<ConfigEntry E>
  12. static const auto& get() noexcept {
  13. return std::get<static_cast<std::size_t>(E)>(content);
  14. }
  15.  
  16. private:
  17. static std::tuple<std::string, int> content;
  18. };
  19.  
  20. std::tuple<std::string, int> ResourceManager::content = {"Rambo", 100};
  21.  
  22. int main() {
  23. std::cout << ResourceManager::get<PLAYER_NAME>() << std::endl;
  24. std::cout << ResourceManager::get<CONNECTION_TIMEOUT>() << std::endl;
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Rambo
100