Regular Expression Solution
Firstly, this can be accomplished with regular expressions rather easily:
bool ok_tret(const std::string& nom){ static const std::regex re{"^[a-zA-Z][a-zA-Z0-9_]+$"}; return std::regex_match(nom, re); } The advantage is obvious: compactness. We are making a single call to a function, ok_tret is basically acting as a wrapper function.
The problem with this some might say is readability: not everyone understands regular expressions, but that can be said of other language features like template metaprogramming and moreover there are many tools online to build your own regular expressions.
Performance Considerations
I tested both the regular expression function and your function, for a million strings, of length 100 characters, randomly distributed. Your function was 36% the total time for mine.
With -O3, it was 2.5% of the total time for minethe regular expression. So the more specific approach seems to be more easily optimised by the compiler.
This is to be expected since a specialised solution will run faster; regular expressions are coded to deal with virtually any matching conditions. However, I suspect this function won't be called as in my test conditions and the performance difference won't come into play.
Some obvious complaints with your code are not to use a const char*, go with,
constexpr char* err4{"ERROR. Init again."}; where you are using two modern C++ features: constant expressions and uniform initialisation.