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

Consider adding dereference operator for signals #130

Open
YarikTH opened this issue Sep 4, 2023 · 0 comments
Open

Consider adding dereference operator for signals #130

YarikTH opened this issue Sep 4, 2023 · 0 comments

Comments

@YarikTH
Copy link
Owner

YarikTH commented Sep 4, 2023

Description

It would be more convenient if to have a sum of two signals we will have

var_signal<int> a = make_var(1);
var_signal<int> b = make_var(1);

int c = *a + *b;

instead of

int c = a.get() + b.get();
//or
int d = a() + b();

It matches existing pointer semantic much more. Also assignment can be considered.

*a = 10;

To do so, some kind of proxy is required, because we can't just return T const& and T&.


Hmm... as a silly though. If we add NOP operator++, then signals can be passed in std algorithms both as source and as a destination.

std::copy(vec.begin(), vec.end(), a);
std::copy(a.begin(), a.end(), std::back_inserter(vec));

Except the MSVC that requires iterators having the type traits(

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