refs #624 Use ref qualifiers.

This commit is contained in:
Mathew Sutcliffe
2016-03-20 00:31:59 +00:00
parent 3001ca1f44
commit 4700cb1602
2 changed files with 3 additions and 11 deletions

View File

@@ -92,10 +92,8 @@ namespace BlackMisc
{
PointerWrapper(typename std::decay<undecayed_type>::type *obj) : m_obj(std::move(*obj)) {}
typename std::decay<undecayed_type>::type const *operator ->() const { return &m_obj; }
typename std::decay<undecayed_type>::type operator *() const { return m_obj; }
// TODO replace operator* above with the following, when our compilers support C++11 ref-qualifiers
//typename std::decay<undecayed_type>::type operator *() const & { return m_obj; }
//typename std::decay<undecayed_type>::type operator *() && { return std::move(m_obj); }
typename std::decay<undecayed_type>::type operator *() const & { return m_obj; }
typename std::decay<undecayed_type>::type operator *() && { return std::move(m_obj); }
private:
const typename std::decay<undecayed_type>::type m_obj;
};

View File

@@ -19,12 +19,6 @@
#include <atomic>
#include <utility>
#if _MSC_VER < 1900
#define BLACK_RVALUE_REF_QUALIFIER
#else
#define BLACK_RVALUE_REF_QUALIFIER &&
#endif
// http://www.drdobbs.com/lock-free-data-structures/184401865
// http://en.cppreference.com/w/cpp/memory/shared_ptr/atomic
@@ -320,7 +314,7 @@ namespace BlackMisc
//! \param function The LockFree values from which this LockFreeMulti was constructed will be passed as arguments to this functor.
//! \return The value returned by the functor, if any.
template <typename F>
auto operator ()(F &&function) BLACK_RVALUE_REF_QUALIFIER -> decltype(function(std::declval<Ts>()...))
auto operator ()(F &&function) && -> decltype(function(std::declval<Ts>()...))
{
return call(std::forward<F>(function), Private::make_index_sequence<sizeof...(Ts)>());
}