[PATCH] D36089: [ELF] - Replace parallelForEach with ranged form.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 08:28:05 PDT 2017


On Wed, Aug 2, 2017 at 2:39 AM George Rimar <grimar at accesssoftek.com> wrote:

> >I suppose for a range algorithm (as opposed to a range adapter) you
> probably just need to take by T & (and T will be deduced to const U if
> needed).
>
>
> Thanks David !
>
>
> I would suggest to use next signature for parallelForEach in LLD then:
>
> template <typename R, class FuncTy> void parallelForEach(const R &Range,
> FuncTy Fn)
>
>
> Because  without `const` for `Range` next call would report warnings:
>
> parallelForEach(std::vector<int>({ 1, 2 }), [](int) {});
> warning C4239: nonstandard extension used: 'argument': conversion from
> 'std::vector<int,std::allocator<int>>' to
> 'std::vector<int,std::allocator<int>> &'
> note: A non-const reference may only be bound to an lvalue.
>
> I know we do not use such calls in LLD, but if one day LLVM's algorithms
> be changed from && to &,
> I think it worth to use const fo them and therefore for LLD algorithms too.
>

Oh, huh, yeah - right you are (I was rather hoping that "T&" would derive T
as "const U" when passed a temporary, but as you've pointed out, it
doesn't).

Yeah, I'd be in favor of what you've done then - passing T&& so temporaries
or locals can be passed by reference without undue copying in either case.

- Dave


>
> George.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170802/9f3d78fe/attachment.html>


More information about the llvm-commits mailing list