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 sugar for the elect() & return single_result idiom #206

Open
jaredhoberock opened this issue May 13, 2016 · 1 comment
Open

Comments

@jaredhoberock
Copy link
Collaborator

jaredhoberock commented May 13, 2016

The idea would be to provide a shorthand for this idiom:

auto lambda = [](auto& self) -> single_result<int>
{
  // each agent computes some result
  int my_result = compute_my_result(self);

  // only one agent needs to return a result
  if(self.elect())
  {
    return my_result;
  }

  return ignore;
}

With some sugar we could have something like:

auto lambda = [](auto& self)
{
  // only one agent needs to return a result
  return elect_value(self, compute_my_result(self));
}

What's nice about the sugar in this example is that it eliminates the requirement to annotate the return type of the lambda with single_result<int>.

@jaredhoberock
Copy link
Collaborator Author

If we do this, we might consider making the current .elect() member function a free function.

@jaredhoberock jaredhoberock added this to the Release0.X milestone Aug 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant