[libcxx-commits] [libcxx] [libcxx] Added segmented iterator for count_if (PR #105888)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 9 10:07:13 PDT 2024
adeel10x wrote:
> > Benchmark compilation was failing due to this error:
> > ```
> > [1/2] /home/adeel/llvm-project/build/bin/clang++ -Wno-unused-command-line-argument -nostdinc++ -isystem /home/adeel/Desktop/llvm-project/build/include/c++/v1 -L/home/adeel/Desktop/llvm-project/build/lib -Wl,-rpath,/home/adeel/Desktop/llvm-project/build/lib -Wall -Wextra -Wshadow -Wfloat-equal -Wold-style-cast -Werror -Wsuggest-override -pedantic -pedantic-errors -Wshorten-64-to-32 -fstrict-aliasing -Wno-deprecated-declarations -Wno-deprecated -Wstrict-aliasing -Wthread-safety -stdlib=libc++ -std=c++11 -MD -MT CMakeFiles/cmTC_8bf2e.dir/posix_regex.cpp.o -MF CMakeFiles/cmTC_8bf2e.dir/posix_regex.cpp.o.d -o CMakeFiles/cmTC_8bf2e.dir/posix_regex.cpp.o -c /home/adeel/Desktop/llvm-project/third-party/benchmark/cmake/posix_regex.cpp
> > FAILED: CMakeFiles/cmTC_8bf2e.dir/posix_regex.cpp.o
> > /home/adeel/llvm-project/build/bin/clang++ -Wno-unused-command-line-argument -nostdinc++ -isystem /home/adeel/Desktop/llvm-project/build/include/c++/v1 -L/home/adeel/Desktop/llvm-project/build/lib -Wl,-rpath,/home/adeel/Desktop/llvm-project/build/lib -Wall -Wextra -Wshadow -Wfloat-equal -Wold-style-cast -Werror -Wsuggest-override -pedantic -pedantic-errors -Wshorten-64-to-32 -fstrict-aliasing -Wno-deprecated-declarations -Wno-deprecated -Wstrict-aliasing -Wthread-safety -stdlib=libc++ -std=c++11 -MD -MT CMakeFiles/cmTC_8bf2e.dir/posix_regex.cpp.o -MF CMakeFiles/cmTC_8bf2e.dir/posix_regex.cpp.o.d -o CMakeFiles/cmTC_8bf2e.dir/posix_regex.cpp.o -c /home/adeel/Desktop/llvm-project/third-party/benchmark/cmake/posix_regex.cpp
> > In file included from /home/adeel/Desktop/llvm-project/third-party/benchmark/cmake/posix_regex.cpp:2:
> > In file included from /home/adeel/Desktop/llvm-project/build/include/c++/v1/string:647:
> > In file included from /home/adeel/Desktop/llvm-project/build/include/c++/v1/string_view:958:
> > In file included from /home/adeel/Desktop/llvm-project/build/include/c++/v1/algorithm:1832:
> > /home/adeel/Desktop/llvm-project/build/include/c++/v1/__algorithm/count_if.h:28:56: error: 'auto' not allowed in lambda parameter before C++14
> > 28 | std::for_each(__first, __last, [&__r, &__pred](const auto& __val) mutable {
> > | ^~~~
> > 1 error generated.
> > ninja: build stopped: subcommand failed.
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > So, I guess I can't use `auto` for lambda parameter type here.
> > ```
> > * For segmented iterators, the lambda argument type would be:`const iterator_traits<Traits::__local_iterator>::value_type&` where Traits is `__segmented_iterator_traits<_SegmentedIterator>`,
> >
> > * For others, it would be: `const iterator_traits<_InputIterator>::value_type&`
> > Should I create separate template functions for segmented and non-segmented iterators to implement this? Just like I had earlier...
> > ```
>
> You should be able to use `[]<class _Tp>(const _Tp&) mutable {...}`.
Can we use the template parameter with lambda expressions before C++20? The benchmarks are being compiled with `-std=c++11`. I am getting a different error again.
https://github.com/llvm/llvm-project/pull/105888
More information about the libcxx-commits
mailing list