1

I'm trying to create a readable function that will contain a large amount of repeating if statement using a section of my code below.

#define if_identifier(finder, to_find) if((finder = msg.find(to_find)) != std::string npos) std::string Utility::Decode(const char* buffer, int &playerID) { std::string msg(buffer); size_t identifier; if_identifier(identifier, "P_ID:[") { } } 

Why does this code cause a type name is not allowed error?

1
  • 1
    Define a function instead of a macro, in the cases where you'd need that. But here, consider using a table of identifiers and a loop instead of multiple near-identical if statements. Think DRY: Don't Repeat Yourself. Commented Sep 25, 2015 at 2:56

1 Answer 1

3

Because junk std::string is there.

Try changing std::string npos to std::string::npos.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.