Skip to content

Don't require optional_last_value's result type to be assignable#85

Merged
fmhess merged 1 commit intoboostorg:developfrom
theuni:no-last-value-result-assign
Feb 6, 2026
Merged

Don't require optional_last_value's result type to be assignable#85
fmhess merged 1 commit intoboostorg:developfrom
theuni:no-last-value-result-assign

Conversation

@theuni
Copy link
Contributor

@theuni theuni commented Feb 2, 2026

As in title. A move-constructible return type should suffice for optional_last_value.

Here's a minimal test-case demonstrating the issue:

#include <boost/signals2/signal.hpp>
#include <cassert>

struct moveonly_data
{
    moveonly_data(int data) : m_data(data){}
    moveonly_data(moveonly_data&&) = default;

    // The assignment operator should not be required here
    moveonly_data& operator=(moveonly_data&&) = default;

    moveonly_data(const moveonly_data&) = delete;
    moveonly_data& operator=(const moveonly_data&) = delete;
    int m_data;
};

moveonly_data moveonly_return_callback(int val)
{
    return {val+1};
}

int main()
{
    boost::signals2::signal<moveonly_data(int)> sig;
    sig.connect(moveonly_return_callback);
    int data{3};
    auto ret = sig(data);
    assert(ret->m_data == 4);
}

With this fix applied, the move-assignment operator can be deleted as expected.

@fmhess fmhess self-assigned this Feb 2, 2026
theuni added a commit to theuni/bitcoin that referenced this pull request Feb 2, 2026
This was necessary to work around an unnecessary boost constraint:
boostorg/signals2#85

Using our own implementation instead, this causes a warning because it's
unused.
theuni added a commit to theuni/bitcoin that referenced this pull request Feb 3, 2026
This was necessary to work around an unnecessary boost constraint:
boostorg/signals2#85

Using our own implementation instead, this causes a warning because it's
unused.
theuni added a commit to theuni/bitcoin that referenced this pull request Feb 3, 2026
This was necessary to work around an unnecessary boost constraint:
boostorg/signals2#85

Using our own implementation instead, this causes a warning because it's
unused.
theuni added a commit to theuni/bitcoin that referenced this pull request Feb 3, 2026
This was necessary to work around an unnecessary boost constraint:
boostorg/signals2#85

Using our own implementation instead, this causes a warning because it's
unused.
@fmhess fmhess merged commit 44c4844 into boostorg:develop Feb 6, 2026
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

Successfully merging this pull request may close these issues.

2 participants