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

Fix is_iterator for container algorithms #1785

Merged
merged 3 commits into from Oct 6, 2015
Merged

Fix is_iterator for container algorithms #1785

merged 3 commits into from Oct 6, 2015

Conversation

dcbdan
Copy link
Contributor

@dcbdan dcbdan commented Oct 5, 2015

  • Fix is_iterator so that SFINAE can work
  • Call projection functions with invoke so that member functions
    can be passed as arguments.

Daniel Bourgeois added 2 commits October 5, 2015 15:26
- This commit fixes is_iterator which failed to use SFINAE properly and
- calls invoke on proj so that member functions can be called
@@ -92,7 +93,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1)
[f, proj](reference t)
{
using hpx::util::get;
get<1>(t) = f(proj(get<0>(t))); //-V573
using hpx::util::invoke;
get<1>(t) = f(invoke(proj, get<0>(t)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should probably be hpx::util::invoke

@hkaiser
Copy link
Member

hkaiser commented Oct 6, 2015

lgtm, thanks!

@AntonBikineev
Copy link
Contributor

@hkaiser: just out of curiosity, what's benefit of using explicit quailification of hpx::util::invoke instead of using declarations in this case?

@hkaiser
Copy link
Member

hkaiser commented Oct 6, 2015

@hkaiser: just out of curiosity, what's benefit of using explicit quailification of hpx::util::invoke instead of using declarations in this case?

Using invoke allows for things like this:

struct A { 
    int foo() { return 42; }
};

std::vector<A> v(43);

parallel::for_each(
    seq, begin(v), end(v),
    [](int i) { cout << i; },
    &A::foo);

@K-ballo
Copy link
Member

K-ballo commented Oct 6, 2015

what's benefit of using explicit quailification of hpx::util::invoke instead of using declarations in this case?

@AntonBikineev It avoids ADL havoc, qualified vs unqualified is always about avoiding ADL. For instance, when std:: arguments are used both hpx::util::invoke and std::invoke are viable matches and the unqualified call is ambiguous. Generic libraries should always do qualified calls unless they explicitly want a call to reach a customization point.

@AntonBikineev
Copy link
Contributor

@K-ballo: thanks for the point. What about this:
using hpx::util::invoke;
(invoke)(something);
/joke/

hkaiser added a commit that referenced this pull request Oct 6, 2015
Fix is_iterator for container algorithms
@hkaiser hkaiser merged commit 9e1dbb9 into master Oct 6, 2015
@hkaiser hkaiser deleted the ca_fix branch October 6, 2015 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants