Static Check Input Parameter is Allowed

Viewed 27

For this code piece:

constexpr string_view nameOk[] = {"name1", "name2");

class Bar {
public:
  void foo(const string& name);
};

...
Bar bar;
bar.foo("name1");  // OK
bar.foo("name2");  // OK
bar.foo("name3");  // NOT OK

Are there any ways to check the input parameter at compile time?

0 Answers
Related