---
name: "std::logic_error"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::logic_error/3cxx"
---

# std::logic\_error(3cxx)

One of two subclasses of exception.

## NAME

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

## SYNOPSIS

`#include <stdexcept>`

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 \*) \_GLIBCXX\_TXN\_SAFE\
 **logic\_error** (const **logic\_error** &)=**default**\
 **logic\_error** (const **string** &\_\_arg) \_GLIBCXX\_TXN\_SAFE\
 **logic\_error** (**logic\_error** &&) noexcept\
 **logic\_error** & **operator=** (const **logic\_error** &)=**default**\
 **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. \

## 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**.

## Author

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