diff options
author | onqtam <vik.kirilov@gmail.com> | 2017-03-28 18:09:00 +0300 |
---|---|---|
committer | onqtam <vik.kirilov@gmail.com> | 2017-05-16 00:22:16 +0300 |
commit | 3bf66ca256eb5259f6ab35303d775f27508b1f42 (patch) | |
tree | 468d02c99d12ebb778fdb9d525942d4949e99f13 /doctest | |
parent | 0cd0607063ca84657b690ba5a6447fa101f09371 (diff) |
using a static assert instead of deleting/hiding the forbidden overload for rvalues - relates #23 relates #48
Diffstat (limited to 'doctest')
-rw-r--r-- | doctest/doctest.h | 11 | ||||
-rw-r--r-- | doctest/parts/doctest_fwd.h | 11 |
2 files changed, 8 insertions, 14 deletions
diff --git a/doctest/doctest.h b/doctest/doctest.h index d4bfd84..968251c 100644 --- a/doctest/doctest.h +++ b/doctest/doctest.h @@ -1415,14 +1415,11 @@ namespace detail } #ifdef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES -#ifdef DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS template<typename T> - ContextBuilder& operator<<(const T&&) = delete; -#else // DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS - private: - template<typename T> - ContextBuilder& operator<<(const T&&); -#endif // DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS + ContextBuilder& operator<<(const T&&) { + DOCTEST_STATIC_ASSERT(deferred_false<T>::value, Cannot_pass_temporaries_or_rvalues_to_the_streaming_operator_because_it_caches_pointers_to_the_passed_objects_for_lazy_evaluation); + return *this; + } #endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES }; diff --git a/doctest/parts/doctest_fwd.h b/doctest/parts/doctest_fwd.h index 7b99156..7081705 100644 --- a/doctest/parts/doctest_fwd.h +++ b/doctest/parts/doctest_fwd.h @@ -1412,14 +1412,11 @@ namespace detail } #ifdef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES -#ifdef DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS template<typename T> - ContextBuilder& operator<<(const T&&) = delete; -#else // DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS - private: - template<typename T> - ContextBuilder& operator<<(const T&&); -#endif // DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS + ContextBuilder& operator<<(const T&&) { + DOCTEST_STATIC_ASSERT(deferred_false<T>::value, Cannot_pass_temporaries_or_rvalues_to_the_streaming_operator_because_it_caches_pointers_to_the_passed_objects_for_lazy_evaluation); + return *this; + } #endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES }; |