Closed dirvine closed 8 years ago
Next follows the condition
# if defined __clang__
# if (__clang_major__ < 2) || (__clang_major__ == 2) && (__clang_minor__ < 9)
# define BOOST_EXPECTED_NO_CXX11_RVALUE_REFERENCE_FOR_THIS
# endif
# elif defined __GNUC__
# if (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ < 40801) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_EXPECTED_NO_CXX11_RVALUE_REFERENCE_FOR_THIS
# endif
# elif defined BOOST_NO_CXX11_REF_QUALIFIERS
# define BOOST_EXPECTED_NO_CXX11_RVALUE_REFERENCE_FOR_THIS
# endif
Please, could you check if Boost defines BOOST_NO_CXX11_REF_QUALIFIERS
?
Thanks Vicente - I added
33 #if defined BOOST_NO_CXX11_REF_QUALIFIERS
34 #error
35 #endif
Which is before the errors and no this is not defined. Hope that helps, let me know and I can try a few more things or give you access to a remote machine with this on it to try. Happy to help though
We suspected that c++1y flags may fix this but we are currently c++11.
Hrr, the problem should be then then is with the clang compiler. Could you try to replace the previous code by?
#if defined BOOST_NO_CXX11_REF_QUALIFIERS
# define BOOST_EXPECTED_NO_CXX11_RVALUE_REFERENCE_FOR_THIS
# endif
Still same error :-( Output is /home/dirvine/Devel/MaidSafe-dirvine/buildclang/boost_1_57_0_Clang_3_5_0/boost/expected/unexpected.hpp:42:32: error: functions that differ only in their return type cannot be overloaded BOOSTFORCEINLINE ErrorType& value() & { return error; }
/home/dirvine/Devel/MaidSafe-dirvine/buildclang/boost_1_57_0_Clang_3_5_0/boost/expected/unexpected.hpp:40:38: note: previous declaration is here
BOOST_FORCEINLINE ErrorType const& value() const & { return error_; }
~~~~~~~~~~~~~~~~ ^
I applied the fix above and also the patch for config.hpp
FYI this patch fixes the error (one of the guys created this) From 10ddc69f0a41103ce170145273e961e66783ee0c Mon Sep 17 00:00:00 2001 From: Lee Clagett code@leeclagett.com Date: Tue, 16 Dec 2014 19:55:05 -0500 Subject: [PATCH 1/1] temporary fix for boost expected
---
.../boost_expected/boost/expected/config.hpp | 3 ++
.../boost_expected/boost/expected/expected.hpp | 52 +++++++++++-----------
.../boost_expected/boost/expected/unexpected.hpp | 8 ++--
3 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/src/third_party_libs/boost_expected/boost/expected/config.hpp b/src/third_party_libs/boost_expected/boost/expected/config.hpp
index 49897a1..00e7551 100644
--- a/src/third_party_libs/boost_expected/boost/expected/config.hpp
+++ b/src/third_party_libs/boost_expected/boost/expected/config.hpp
@@ -81,4 +81,7 @@
# endif
+#define BOOST_EXPECTED_CONSTEXPR_CPP14
+
+
#endif // BOOST_EXPECTED_CONFIG_HPP
diff --git a/src/third_party_libs/boost_expected/boost/expected/expected.hpp b/src/third_party_libs/boost_expected/boost/expected/expected.hpp
index 7e0ed7e..9e0339a 100644
--- a/src/third_party_libs/boost_expected/boost/expected/expected.hpp
+++ b/src/third_party_libs/boost_expected/boost/expected/expected.hpp
@@ -693,21 +693,21 @@ private:
#if ! defined BOOST_EXPECTED_NO_CXX11_RVALUE_REFERENCE_FOR_THIS
BOOST_CONSTEXPR const bool& contained_has_value() const& { return base_type::has_value; }
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
bool& contained_has_value() & { return base_type::has_value; }
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
bool&& contained_has_value() && { return std::move(base_type::has_value); }
BOOST_CONSTEXPR const value_type& contained_val() const& { return base_type::storage.val(); }
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
value_type& contained_val() & { return base_type::storage.val(); }
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
value_type&& contained_val() && { return std::move(base_type::storage.val()); }
BOOST_CONSTEXPR const error_type& contained_err() const& { return base_type::storage.err(); }
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
error_type& contained_err() & { return base_type::storage.err(); }
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
error_type&& contained_err() && { return std::move(base_type::storage.err()); }
#else
@@ -996,12 +996,12 @@ public:
)
;
}
- BOOST_CONSTEXPR value_type& value() &
+ BOOST_EXPECTED_CONSTEXPR_CPP14 value_type& value() &
{
if (!valid()) error::rethrow<error_type>(contained_err());
return contained_val();
}
- BOOST_CONSTEXPR value_type&& value() &&
+ BOOST_EXPECTED_CONSTEXPR_CPP14 value_type&& value() &&
{
if (!valid()) error::rethrow<error_type>(contained_err());
return std::move(contained_val());
@@ -1031,11 +1031,11 @@ public:
return contained_val();
}
- BOOST_CONSTEXPR value_type& operator*() & BOOST_NOEXCEPT
+ BOOST_EXPECTED_CONSTEXPR_CPP14 value_type& operator*() & BOOST_NOEXCEPT
{
return contained_val();
}
- BOOST_CONSTEXPR value_type&& operator*() && BOOST_NOEXCEPT
+ BOOST_EXPECTED_CONSTEXPR_CPP14 value_type&& operator*() && BOOST_NOEXCEPT
{
return constexpr_move(contained_val());
}
@@ -1056,7 +1056,7 @@ public:
return dataptr();
}
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
value_type* operator->() BOOST_NOEXCEPT
{
return dataptr();
@@ -1067,11 +1067,11 @@ public:
{
return contained_err();
}
- BOOST_CONSTEXPR error_type& error() & BOOST_NOEXCEPT
+ BOOST_EXPECTED_CONSTEXPR_CPP14 error_type& error() & BOOST_NOEXCEPT
{
return contained_err();
}
- BOOST_CONSTEXPR error_type&& error() && BOOST_NOEXCEPT
+ BOOST_EXPECTED_CONSTEXPR_CPP14 error_type&& error() && BOOST_NOEXCEPT
{
return constexpr_move(contained_err());
}
@@ -1093,7 +1093,7 @@ public:
return unexpected_type<error_type>(contained_err());
}
- BOOST_CONSTEXPR unexpected_type<error_type> get_unexpected() && BOOST_NOEXCEPT
+ BOOST_EXPECTED_CONSTEXPR_CPP14 unexpected_type<error_type> get_unexpected() && BOOST_NOEXCEPT
{
return unexpected_type<error_type>(constexpr_move(contained_err()));
}
@@ -1117,7 +1117,7 @@ public:
}
template <class V>
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS value_type value_or(V&& v) &&
+ BOOST_EXPECTED_CONSTEXPR_CPP14 value_type value_or(V&& v) &&
{
return *this
? constexpr_move(const_cast<typename rebind<value_type>::type&>(*this).contained_val())
@@ -1133,7 +1133,7 @@ public:
}
template <class Exception>
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS value_type value_or_throw() &&
+ BOOST_EXPECTED_CONSTEXPR_CPP14 value_type value_or_throw() &&
{
return *this
? constexpr_move(const_cast<typename rebind<value_type>::type&>(*this).contained_val())
@@ -1161,7 +1161,7 @@ public:
#if ! defined BOOST_EXPECTED_NO_CXX11_RVALUE_REFERENCE_FOR_THIS
inline BOOST_CONSTEXPR expected_detail::unwrap_result_type_t<expected> unwrap() const&;
- inline BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS expected_detail::unwrap_result_type_t<expected> unwrap() &&;
+ inline BOOST_EXPECTED_CONSTEXPR_CPP14 expected_detail::unwrap_result_type_t<expected> unwrap() &&;
#else
inline BOOST_CONSTEXPR expected_detail::unwrap_result_type_t<expected> unwrap() const;
#endif
@@ -1527,15 +1527,15 @@ private:
#if ! defined BOOST_EXPECTED_NO_CXX11_RVALUE_REFERENCE_FOR_THIS
BOOST_CONSTEXPR const bool& contained_has_value() const& { return base_type::has_value; }
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
bool& contained_has_value() & { return base_type::has_value; }
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
bool&& contained_has_value() && { return std::move(base_type::has_value); }
BOOST_CONSTEXPR const error_type& contained_err() const& { return base_type::storage.err(); }
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
error_type& contained_err() & { return base_type::storage.err(); }
- BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
+ BOOST_EXPECTED_CONSTEXPR_CPP14
error_type&& contained_err() && { return std::move(base_type::storage.err()); }
#else
@@ -1733,11 +1733,11 @@ public:
{
return contained_err();
}
- BOOST_CONSTEXPR error_type& error() & BOOST_NOEXCEPT
+ BOOST_EXPECTED_CONSTEXPR_CPP14 error_type& error() & BOOST_NOEXCEPT
{
return contained_err();
}
- BOOST_CONSTEXPR error_type&& error() && BOOST_NOEXCEPT
+ BOOST_EXPECTED_CONSTEXPR_CPP14 error_type&& error() && BOOST_NOEXCEPT
{
return constexpr_move(contained_err());
}
@@ -1758,7 +1758,7 @@ public:
return unexpected_type<error_type>(contained_err());
}
- BOOST_CONSTEXPR unexpected_type<error_type> get_unexpected() && BOOST_NOEXCEPT
+ BOOST_EXPECTED_CONSTEXPR_CPP14 unexpected_type<error_type> get_unexpected() && BOOST_NOEXCEPT
{
return unexpected_type<error_type>(constexpr_move(contained_err()));
}
@@ -1771,7 +1771,7 @@ public:
#if ! defined BOOST_EXPECTED_NO_CXX11_RVALUE_REFERENCE_FOR_THIS
inline BOOST_CONSTEXPR expected_detail::unwrap_result_type_t<expected> unwrap() const&;
- inline BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS expected_detail::unwrap_result_type_t<expected> unwrap() &&;
+ inline BOOST_EXPECTED_CONSTEXPR_CPP14 expected_detail::unwrap_result_type_t<expected> unwrap() &&;
#else
inline BOOST_CONSTEXPR expected_detail::unwrap_result_type_t<expected> unwrap() const;
#endif
@@ -2338,7 +2338,7 @@ namespace expected_detail
return expected_detail::unwrap(*this);
}
template <class T, class E>
- inline BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS expected_detail::unwrap_result_type_t<expected<T,E>>
+ inline BOOST_EXPECTED_CONSTEXPR_CPP14 expected_detail::unwrap_result_type_t<expected<T,E>>
expected<T,E>::unwrap() &&
{
return expected_detail::unwrap(*this);
diff --git a/src/third_party_libs/boost_expected/boost/expected/unexpected.hpp b/src/third_party_libs/boost_expected/boost/expected/unexpected.hpp
index 609b83a..9e960d7 100644
--- a/src/third_party_libs/boost_expected/boost/expected/unexpected.hpp
+++ b/src/third_party_libs/boost_expected/boost/expected/unexpected.hpp
@@ -42,12 +42,12 @@ namespace boost
{
return error_;
}
- BOOST_CONSTEXPR
+ BOOST_EXPECTED_CONSTEXPR_CPP14
BOOST_FORCEINLINE ErrorType& value() &
{
return error_;
}
- BOOST_CONSTEXPR
+ BOOST_EXPECTED_CONSTEXPR_CPP14
BOOST_FORCEINLINE ErrorType& value() &&
{
return constexpr_move(error_);
@@ -164,11 +164,11 @@ namespace boost
return !(x < y);
}
- inline BOOST_CONSTEXPR bool operator<(const unexpected_type<std::exception_ptr>& x, const unexpected_type<std::exception_ptr>& y)
+ inline BOOST_CONSTEXPR bool operator<(const unexpected_type<std::exception_ptr>&, const unexpected_type<std::exception_ptr>&)
{
return false;
}
- inline BOOST_CONSTEXPR bool operator>(const unexpected_type<std::exception_ptr>& x, const unexpected_type<std::exception_ptr>& y)
+ inline BOOST_CONSTEXPR bool operator>(const unexpected_type<std::exception_ptr>&, const unexpected_type<std::exception_ptr>&)
{
return false;
}
--
2.0.4
Your patch consists in removing the constexpr, which is not the goal, isn't it? Have you run the unit test?
if you want to remove them just change the 5 by 7 in line 17
# if defined __clang__
# if (__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 7)
# define BOOST_EXPECTED_NO_CXX11_MOVE_ACCESSORS
# endif
There however some issues in the code that uses BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS
, that I will address soon.
On Thu, Dec 18, 2014 at 7:21 AM, Vicente J. Botet Escriba < notifications@github.com> wrote:
Your patch consists in removing the constexpr, which is not the goal, isn't it?
No, although we have msvc folks in our code so cannot use constexpr across our code base right now (OK in ifdefed blocks like this though) :-( Well until MS get msvc15 out (ctp aside)
Have you run the unit test?
No but I will, I suspect efficiency may be the loser here though. I will try and let you knwo though.
if you want to remove them just change the 5 by 7 in line 17
if defined clang
if (clang_major < 3) || (clang_major == 3) && (clang_minor < 7)
define BOOST_EXPECTED_NO_CXX11_MOVE_ACCESSORS
endif
Thanks for that
There however some issues in the code that uses BOOST_EXPECTED_CONSTEXPR_IF_MOVE_ACCESSORS, that I will address soon.
Cheers I appreciate this lib, it is long overdue in c++ thanks agian
David Irvine twitter: @metaquestions blog: http://metaquestions.me
The patch listed here was written by me just as a hack to get it to compile. The issue is that constexpr
implies const
in C++11. So clang in C++11 mode will add the const
specifier to those member functions, and will result in two of them being exact duplicates (except for the return value). The &&
ref-qualifier version is likely also illegal with the const added. My intent with that macro was to have a check for C++11 vs C++14 modes.
The patch make our code compile on Clang, but on Windows it works when compiler warning 4714 is disabled.
Please, could you try https://github.com/ptal/expected/commit/42cf68d6688c6a9879c28e1eeb82a7109979eff0
We have tried this and it seems to work as we would expect. There seems to be an ODR issue in line 418 which we added a static (not sure this is entirely valid) so it now reads BOOST_CONSTEXPR static struct only_set_valid_t{} only_set_valid{};
The issue showed up in Windows with MSVC2013 if that helps. In any case with this static added all seems well. We do not have boost_test built but can do something there to try it unless you have a MSVC lying around.
I should add, we will try and get the tests put into our CI suite, this will test cross platform and compiler (x86 amd64 arm, osx, win, linux, bsd for now). This will help us all a little I hope.
Hi, I don't remember where we are with this issue. Please could you tell me?
Including expected.hpp with Ubuntu clang version 3.6.0-svn224230-1~exp1 (trunk) (based on LLVM 3.6.0)
Gives several errors about return types (output below) /home/dirvine/Devel/MaidSafe-dirvine/buildclang/boost_1_57_0_Clang_3_5_0/boost/expected/unexpected.hpp:46:34: error: functions that differ only in their return type cannot be overloaded BOOST_FORCEINLINE ErrorType& value() &