---
name: "std::logic_error"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::logic_error"
---

# std::logic\_error(3)

One of two subclasses of exception.

## NAME

std::logic\_error - One of two subclasses of exception.

## SYNOPSIS

\#include \<stdexcept\_except.h\>

Inherits **std::exception**.

Inherited by **\_\_gnu\_pbds::container\_error**, **std::domain\_error**, **std::experimental::fundamentals\_v1::bad\_optional\_access**, **std::future\_error**, **std::invalid\_argument**, **std::length\_error**, and **std::out\_of\_range**.

### Public Member Functions

**logic\_error** (const char \*)\
 **logic\_error** (const logic\_error &) noexcept\
 **logic\_error** (const **string** &\_\_arg)\
 **logic\_error** (logic\_error &&) noexcept\
 **logic\_error** & **operator=** (const **logic\_error** &) noexcept\
 **logic\_error** & **operator=** (**logic\_error** &&) noexcept\
 virtual const char \* **what** () const noexcept\

## Detailed Description

One of two subclasses of exception.

Logic errors represent problems in the internal logic of a program; in theory, these are preventable, and even detectable before the program runs (e.g., violations of class invariants).

## Constructor & Destructor Documentation

### std::logic\_error::logic\_error (const string & \_\_arg) \[explicit\]

Takes a character string describing the error.

References **logic\_error()**.

Referenced by **logic\_error()**.

## Member Function Documentation

### virtual const char \* std::logic\_error::what () const \[virtual\], \[noexcept\]

Returns a C-style character string describing the general cause of the current error (the same string passed to the ctor).

Reimplemented from **std::exception**.

Reimplemented in **std::future\_error**.

References **what()**.

Referenced by **what()**.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
