8000 GitHub - bkietz/string_enum: simple logarithmic time lookup of strings at compile time, with no macros
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bkietz/string_enum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

string enumerations

simple logarithmic time lookup of strings, also at compile time

no macros

int get_color()
{
  constexpr auto color = rekt::make_string_enum("red", "green", "blue");

  std::string user_value;
  std::cout << "pick a color: ";
  std::cin >> user_value;

  switch (color(user_value))
  {
  case color("red"):
    return 0xf00;
  case color("green"):
    return 0x0f0;
  case color("blue"):
    return 0x0f0;
  default:
    std::cout << "sorry, I don't know that one. Please enter hex value:\n0x";
    std::cin >> std::hex >> user_value;
    return std::stoi(user_value);
  };
}

About

simple logarithmic time lookup of strings at compile time, with no macros

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0