mirror of
https://github.com/boostorg/optional.git
synced 2025-07-15 21:32:17 +02:00
fixed optional<optional<T>&> case
This commit is contained in:
@ -12,6 +12,8 @@
|
||||
#ifndef BOOST_OPTIONAL_TEST_TESTABKE_CLASSES_AK_07JAN2015_HPP
|
||||
#define BOOST_OPTIONAL_TEST_TESTABKE_CLASSES_AK_07JAN2015_HPP
|
||||
|
||||
#include "boost/optional/optional.hpp"
|
||||
|
||||
struct ScopeGuard // no copy/move ctor/assign
|
||||
{
|
||||
int val_;
|
||||
@ -74,13 +76,23 @@ struct has_arrow<int>
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct has_arrow< boost::optional<int> >
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
int& val(int& i) { return i; }
|
||||
int& val(Abstract& a) { return a.val(); }
|
||||
int& val(Impl& a) { return a.val(); }
|
||||
int& val(ScopeGuard& g) { return g.val(); }
|
||||
template <typename T> int& val(T& o) { return *o; }
|
||||
|
||||
const int& val(const int& i) { return i; }
|
||||
const int& val(const Abstract& a) { return a.val(); }
|
||||
const int& val(const Impl& a) { return a.val(); }
|
||||
const int& val(const ScopeGuard& g) { return g.val(); }
|
||||
template <typename T> const int& val(const T& o) { return *o; }
|
||||
|
||||
bool operator==(const Abstract& l, const Abstract& r) { return l.val() == r.val(); }
|
||||
bool operator==(const ScopeGuard& l, const ScopeGuard& r) { return l.val() == r.val(); }
|
||||
|
Reference in New Issue
Block a user