---
name: "std::_Optional_base"
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::_Optional_base"
---

# std::\_Optional\_base(3cxx)

Class template that provides copy/move constructors of optional.

## NAME

std::\_Optional\_base\< \_Tp, bool, bool \> - Class template that provides copy/move constructors of optional.

## SYNOPSIS

`#include <optional>`

Inherits std::\_Optional\_base\_impl\< \_Tp, \_Dp \>.

Inherited by **std::experimental::fundamentals\_v1::optional\< \_Tp \>**` [private]`, **std::optional\< \_Tp \>**` [private]`, and std::ranges::\_\_detail::\_\_non\_propagating\_cache\< \_Tp \>` [protected]`.

### Public Member Functions

constexpr **\_Optional\_base** (**\_Optional\_base** &&\_\_other) noexcept(is\_nothrow\_move\_constructible\_v\< \_Tp \>)\
 constexpr **\_Optional\_base** (const **\_Optional\_base** &\_\_other)\
 template\<typename... \_Args, **enable\_if\_t**\< is\_constructible\_v\< \_Tp, \_Args... \>, bool \>  = false\> constexpr **\_Optional\_base** (in\_place\_t, **\_Args** &&... **\_\_args**)\
 template\<**typename** \_Up , typename... \_Args, **enable\_if\_t**\< is\_constructible\_v\< \_Tp, **initializer\_list**\< \_Up \> &, \_Args... \>, bool \>  = false\> constexpr **\_Optional\_base** (in\_place\_t, **initializer\_list**\< \_Up \> **\_\_il**, **\_Args** &&... **\_\_args**)\
 **\_Optional\_base** & **operator=** (**\_Optional\_base** &&)=**default**\
 **\_Optional\_base** & **operator=** (const **\_Optional\_base** &)=**default**\

### Public Attributes

\_Optional\_payload\< \_Tp \> **\_M\_payload**\

### Protected Types

**using** **\_Stored\_type** = **remove\_const\_t**\< \_Tp \>\

### Protected Member Functions

template\<typename... \_Args\> constexpr **void** **\_M\_construct** (**\_Args** &&... **\_\_args**) noexcept(is\_nothrow\_constructible\_v\< **\_Stored\_type**, \_Args... \>)\
 constexpr **void** **\_M\_destruct** () noexcept\
 constexpr const \_Tp & **\_M\_get** () const noexcept\
 constexpr \_Tp & **\_M\_get** () noexcept\
 constexpr bool **\_M\_is\_engaged** () const noexcept\
 constexpr **void** **\_M\_reset** () noexcept\

## Detailed Description

### template\<typename \_Tp, bool = is\_trivially\_copy\_constructible\_v\<\_Tp\>, bool = is\_trivially\_move\_constructible\_v\<\_Tp\>\>

struct std::\_Optional\_base\< \_Tp, bool, bool \>"Class template that provides copy/move constructors of optional.

Such a separate base class template is necessary in order to conditionally make copy/move constructors trivial.

When the contained value is trivially copy/move constructible, the copy/move constructors of \_Optional\_base will invoke the trivial copy/move constructor of \_Optional\_payload. Otherwise, they will invoke \_Optional\_payload(bool, const \_Optional\_payload&) or \_Optional\_payload(bool, \_Optional\_payload&&) to initialize the contained value, if copying/moving an engaged optional.

Whether the other special members are trivial is determined by the \_Optional\_payload\<\_Tp\> specialization used for the \_M\_payload member.

**See also**

optional, \_Enable\_special\_members

## Author

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