Loading...
Searching...
No Matches
Optional< Value > Class Template Reference

A simple optional type. More...

#include <juce_Optional.h>

Public Member Functions

 Optional ()=default
 
 Optional (const Optional &)=default
 
 Optional (Optional &&)=default
 
Optionaloperator= (const Optional &)=default
 
Optionaloperator= (Optional &&)=default
 
 Optional (Nullopt) noexcept
 
template<typename Head , typename... Tail, std::enable_if_t<! IsOptional< std::decay_t< Head > >::value, int > = 0>
 Optional (Head &&head, Tail &&... tail) noexcept(std::is_nothrow_constructible_v< std::optional< Value >, Head, Tail... >)
 
template<typename Other >
 Optional (const Optional< Other > &other) noexcept(std::is_nothrow_constructible_v< std::optional< Value >, const std::optional< Other > & >)
 
template<typename Other >
 Optional (Optional< Other > &&other) noexcept(std::is_nothrow_constructible_v< std::optional< Value >, std::optional< Other > && >)
 
template<typename Other , std::enable_if_t<! IsOptional< std::decay_t< Other > >::value, int > = 0>
Optionaloperator= (Other &&other) noexcept(std::is_nothrow_assignable_v< std::optional< Value >, Other >)
 
template<typename Other >
Optionaloperator= (const Optional< Other > &other) noexcept(std::is_nothrow_assignable_v< std::optional< Value >, const std::optional< Other > & >)
 
template<typename Other >
Optionaloperator= (Optional< Other > &&other) noexcept(std::is_nothrow_assignable_v< std::optional< Value >, std::optional< Other > && >)
 
template<typename... Other>
auto & emplace (Other &&... other)
 
void reset () noexcept
 
void swap (Optional &other) noexcept(std::is_nothrow_swappable_v< std::optional< Value > >)
 
decltype(auto) operator-> ()
 
decltype(auto) operator-> () const
 
decltype(auto) operator* ()
 
decltype(auto) operator* () const
 
 operator bool () const noexcept
 
bool hasValue () const noexcept
 
template<typename U >
decltype(auto) orFallback (U &&fallback) const &
 
template<typename U >
decltype(auto) orFallback (U &&fallback) &
 

Detailed Description

template<typename Value>
class Optional< Value >

A simple optional type.

In new code, you should probably prefer using std::optional directly.

This is intended to stand-in for std::optional while JUCE's minimum supported language standard is lower than C++17. When the minimum language standard moves to C++17, this class will probably be deprecated, in much the same way that juce::ScopedPointer was deprecated in favour of std::unique_ptr after C++11.

This isn't really intended to be used by JUCE clients. Instead, it's to be used internally in JUCE code, with an API close-enough to std::optional that the types can be swapped with fairly minor disruption at some point in the future, but without breaking any public APIs.

Constructor & Destructor Documentation

◆ Optional() [1/7]

template<typename Value >
Optional< Value >::Optional ( )
default

◆ Optional() [2/7]

template<typename Value >
Optional< Value >::Optional ( const Optional< Value > & )
default

◆ Optional() [3/7]

template<typename Value >
Optional< Value >::Optional ( Optional< Value > && )
default

◆ Optional() [4/7]

template<typename Value >
Optional< Value >::Optional ( Nullopt )
noexcept

◆ Optional() [5/7]

template<typename Value >
template<typename Head , typename... Tail, std::enable_if_t<! IsOptional< std::decay_t< Head > >::value, int > = 0>
Optional< Value >::Optional ( Head && head,
Tail &&... tail )
noexcept

◆ Optional() [6/7]

template<typename Value >
template<typename Other >
Optional< Value >::Optional ( const Optional< Other > & other)
noexcept

◆ Optional() [7/7]

template<typename Value >
template<typename Other >
Optional< Value >::Optional ( Optional< Other > && other)
noexcept

Member Function Documentation

◆ operator=() [1/5]

template<typename Value >
Optional & Optional< Value >::operator= ( const Optional< Value > & )
default

◆ operator=() [2/5]

template<typename Value >
Optional & Optional< Value >::operator= ( Optional< Value > && )
default

◆ operator=() [3/5]

template<typename Value >
template<typename Other , std::enable_if_t<! IsOptional< std::decay_t< Other > >::value, int > = 0>
Optional & Optional< Value >::operator= ( Other && other)
noexcept

◆ operator=() [4/5]

template<typename Value >
template<typename Other >
Optional & Optional< Value >::operator= ( const Optional< Other > & other)
noexcept

◆ operator=() [5/5]

template<typename Value >
template<typename Other >
Optional & Optional< Value >::operator= ( Optional< Other > && other)
noexcept

◆ emplace()

template<typename Value >
template<typename... Other>
auto & Optional< Value >::emplace ( Other &&... other)

◆ reset()

template<typename Value >
void Optional< Value >::reset ( )
noexcept

◆ swap()

template<typename Value >
void Optional< Value >::swap ( Optional< Value > & other)
noexcept

◆ operator->() [1/2]

template<typename Value >
decltype(auto) Optional< Value >::operator-> ( )

◆ operator->() [2/2]

template<typename Value >
decltype(auto) Optional< Value >::operator-> ( ) const

◆ operator*() [1/2]

template<typename Value >
decltype(auto) Optional< Value >::operator* ( )

◆ operator*() [2/2]

template<typename Value >
decltype(auto) Optional< Value >::operator* ( ) const

◆ operator bool()

template<typename Value >
Optional< Value >::operator bool ( ) const
explicitnoexcept

◆ hasValue()

template<typename Value >
bool Optional< Value >::hasValue ( ) const
noexcept

◆ orFallback() [1/2]

template<typename Value >
template<typename U >
decltype(auto) Optional< Value >::orFallback ( U && fallback) const &

◆ orFallback() [2/2]

template<typename Value >
template<typename U >
decltype(auto) Optional< Value >::orFallback ( U && fallback) &

The documentation for this class was generated from the following file:
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram