|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Fix old-style casts |
|
|
|
|
|
|
|
|
|
|
|
template<class T> |
|
|
template<class T> |
|
|
struct Wrapper |
|
|
struct Wrapper |
|
|
{ |
|
|
{ |
|
|
template<class TT, class G, std::enable_if_t<std::is_constructible<T, TT>::value, int> = 0> |
|
|
template<class TT, class G, std::enable_if_t<std::is_constructible<T, TT>::value, int> = 0> |
|
|
explicit Wrapper(TT&& value, G&& g) noexcept(noexcept(Wrapper{(T&&) value})) : Wrapper((T&&) value) |
|
|
|
|
|
|
|
|
explicit Wrapper(TT&& value, G&& g) noexcept(noexcept(Wrapper{value})) : Wrapper(value) |
|
|
{ |
|
|
{ |
|
|
g.release(); |
|
|
g.release(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
struct Wrapper<T&> |
|
|
struct Wrapper<T&> |
|
|
{ |
|
|
{ |
|
|
template<class TT, class G, std::enable_if_t<std::is_convertible<TT, T&>::value, int> = 0> |
|
|
template<class TT, class G, std::enable_if_t<std::is_convertible<TT, T&>::value, int> = 0> |
|
|
explicit Wrapper(TT&& value, G&& g) noexcept(noexcept(static_cast<T&>((TT&&) value))) : m_value((T&) value) |
|
|
|
|
|
|
|
|
explicit Wrapper(TT&& value, G&& g) noexcept(noexcept(static_cast<T&>(value))) : m_value(static_cast<T&>(value)) |
|
|
{ |
|
|
{ |
|
|
g.release(); |
|
|
g.release(); |
|
|
} |
|
|
} |