Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot overload operator>> for safe_numerics::safe #105

Closed
Eelis opened this issue Mar 30, 2021 · 5 comments
Closed

Cannot overload operator>> for safe_numerics::safe #105

Eelis opened this issue Mar 30, 2021 · 5 comments

Comments

@Eelis
Copy link
Contributor

Eelis commented Mar 30, 2021

#include <boost/safe_numerics/safe_integer.hpp>
struct X {};
using I = boost::safe_numerics::safe<int64_t>;
void operator>>(X, I);
void f(X x, I i) { x >> i; } // causes error deep inside SafeNumerics headers

https://godbolt.org/z/eozM1PqW8

@Eelis
Copy link
Contributor Author

Eelis commented Apr 3, 2021

I think the cause is that there's a bad catchall operator>> for safe_base that only disables itself if the lhs is derived from std::ios_base:

template<class T, class U>
typename boost::lazy_enable_if_c<
(! std::is_base_of<std::ios_base, T>::value)
&& (is_safe<T>::value || is_safe<U>::value),
right_shift_result<T, U>
>::type
constexpr inline operator>>(const T & t, const U & u){

@robertramey
Copy link
Member

Your correct. I'm working on fixing it in a definitive way as we "speak".

@robertramey
Copy link
Member

This should be fixed by now on the develop branch. Also added a test for it so it doesn't come back. We'll leave this message until a 2nd person has confirmed it.

@robertramey
Copy link
Member

closed/fixed

@Eelis
Copy link
Contributor Author

Eelis commented May 24, 2021

Sweet, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants