Skip to content

no match for 'operator=' (operand types are 'const rxcpp::util::error_ptr' {aka 'const std::__exception_ptr::exception_ptr'} and 'std::remove_reference<const std::__exception_ptr::exception_ptr&>::type' {aka 'const std::__exception_ptr::exception_ptr'}) #611

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

Open
HOMODELUNA opened this issue Mar 5, 2025 · 1 comment

Comments

@HOMODELUNA
Copy link

Position

error: In file included from /root/mock-ability/build/.packages/r/rxcpp/9002d9be/725e51fe81b74141ade9efbd3ccaf900/include/rxcpp/rx-includes.hpp:206,
                 from /root/mock-ability/build/.packages/r/rxcpp/9002d9be/725e51fe81b74141ade9efbd3ccaf900/include/rxcpp/rx.hpp:8,
                 from /tmp/.xmake0/250305/_F49A970EF5E44D8A9D9305921FD57B9F.cpp:4:
/root/mock-ability/build/.packages/r/rxcpp/9002d9be/725e51fe81b74141ade9efbd3ccaf900/include/rxcpp/rx-notification.hpp: In member function 'rxcpp::notifications::notification<T>::on_error_notification& rxcpp::notifications::notification<T>::on_error_notification::operator=(rxcpp::notifications::notification<T>::on_error_notification)':
/root/mock-ability/build/.packages/r/rxcpp/9002d9be/725e51fe81b74141ade9efbd3ccaf900/include/rxcpp/rx-notification.hpp:153:88: error: no match for 'operator=' (operand types are 'const rxcpp::util::error_ptr' {aka 'const std::__exception_ptr::exception_ptr'} and 'std::remove_reference<const std::__exception_ptr::exception_ptr&>::type' {aka 'const std::__exception_ptr::exception_ptr'})
  153 |         on_error_notification& operator=(on_error_notification o) { ep = std::move(o.ep); return *this; }
      |  

Problem

in rx-hotification.hpp, on_error_notification has a const error_ptr, it can't e reassigned:

    struct on_error_notification : public base {
        on_error_notification(rxu::error_ptr ep) : ep(ep) {
        }
        on_error_notification(const on_error_notification& o) : ep(o.ep) {}
        on_error_notification(const on_error_notification&& o) : ep(std::move(o.ep)) {}
        // here reassigned a const std::exception_ptr
        on_error_notification& operator=(on_error_notification o) { ep = std::move(o.ep); return *this; }
        void out(std::ostream& os) const override {
            os << "on_error(";
            os << rxu::what(ep);
            os << ")";
        }
        bool equals(const typename base::type& other) const override {
            bool result = false;
            // not trying to compare exceptions
            other->accept(make_subscriber<T>(make_observer_dynamic<T>([](T){}, [&result](rxu::error_ptr){
                result = true;
            })));
            return result;
        }
        void accept(const typename base::observer_type& o) const & override{
            o.on_error(ep);
        }

        void accept(const typename base::observer_type& o) && override{
            o.on_error(ep);
        }
        const rxu::error_ptr ep; // it is declared as const
    };

Solution(maybe)

is this error_ptr defined const on_purpose? if not, maybe it should be declared without const.

@HOMODELUNA
Copy link
Author

#612

here is the corresponding PR

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

1 participant