22 Diagnostics library [diagnostics]

22.2 Exception classes [std.exceptions]

22.2.2 Class logic_­error [logic.error]

namespace std {
  class logic_error : public exception {
  public:
    explicit logic_error(const string& what_arg);
    explicit logic_error(const char* what_arg);
  };
}

The class logic_­error defines the type of objects thrown as exceptions to report errors presumably detectable before the program executes, such as violations of logical preconditions or class invariants.

logic_error(const string& what_arg);

Effects: Constructs an object of class logic_­error.

Postconditions: strcmp(what(), what_­arg.c_­str()) == 0.

logic_error(const char* what_arg);

Effects: Constructs an object of class logic_­error.

Postconditions: strcmp(what(), what_­arg) == 0.