Page MenuHomePhabricator

[libc++] Implement ranges::clamp
Needs ReviewPublic

Authored by philnik on May 23 2022, 4:33 AM.

Details

Reviewers
ldionne
Mordante
var-const
Group Reviewers
Restricted Project

Diff Detail

Unit TestsFailed

TimeTest
1,410 mslibcxx CI Assertions enabled > llvm-libc++-shared-cfg-in.std/algorithms/alg_sorting/alg_clamp::ranges.clamp.pass.cpp
Script: -- : 'COMPILED WITH'; /usr/bin/c++ /home/libcxx-builder/.buildkite-agent/builds/9d04f8de409b-1/llvm-project/libcxx-ci/libcxx/test/std/algorithms/alg.sorting/alg.clamp/ranges.clamp.pass.cpp --target=x86_64-unknown-linux-gnu -nostdinc++ -I /home/libcxx-builder/.buildkite-agent/builds/9d04f8de409b-1/llvm-project/libcxx-ci/build/generic-assertions/include/c++/v1 -I /home/libcxx-builder/.buildkite-agent/builds/9d04f8de409b-1/llvm-project/libcxx-ci/build/generic-assertions/include/c++/v1 -I /home/libcxx-builder/.buildkite-agent/builds/9d04f8de409b-1/llvm-project/libcxx-ci/libcxx/test/support -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_ASSERTIONS=1 -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -lc++experimental -nostdlib++ -L /home/libcxx-builder/.buildkite-agent/builds/9d04f8de409b-1/llvm-project/libcxx-ci/build/generic-assertions/lib -Wl,-rpath,/home/libcxx-builder/.buildkite-agent/builds/9d04f8de409b-1/llvm-project/libcxx-ci/build/generic-assertions/lib -lc++ -pthread -o /home/libcxx-builder/.buildkite-agent/builds/9d04f8de409b-1/llvm-project/libcxx-ci/build/generic-assertions/test/std/algorithms/alg.sorting/alg.clamp/Output/ranges.clamp.pass.cpp.dir/t.tmp.exe
1,490 mslibcxx CI Debug iterators > llvm-libc++-shared-cfg-in.std/algorithms/alg_sorting/alg_clamp::ranges.clamp.pass.cpp
Script: -- : 'COMPILED WITH'; /usr/bin/c++ /home/libcxx-builder/.buildkite-agent/builds/d12771cc4cec-1/llvm-project/libcxx-ci/libcxx/test/std/algorithms/alg.sorting/alg.clamp/ranges.clamp.pass.cpp --target=x86_64-unknown-linux-gnu -nostdinc++ -I /home/libcxx-builder/.buildkite-agent/builds/d12771cc4cec-1/llvm-project/libcxx-ci/build/generic-debug-iterators/include/c++/v1 -I /home/libcxx-builder/.buildkite-agent/builds/d12771cc4cec-1/llvm-project/libcxx-ci/build/generic-debug-iterators/include/c++/v1 -I /home/libcxx-builder/.buildkite-agent/builds/d12771cc4cec-1/llvm-project/libcxx-ci/libcxx/test/support -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Wno-macro-redefined -D_LIBCPP_DEBUG=1 -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -lc++experimental -nostdlib++ -L /home/libcxx-builder/.buildkite-agent/builds/d12771cc4cec-1/llvm-project/libcxx-ci/build/generic-debug-iterators/lib -Wl,-rpath,/home/libcxx-builder/.buildkite-agent/builds/d12771cc4cec-1/llvm-project/libcxx-ci/build/generic-debug-iterators/lib -lc++ -pthread -o /home/libcxx-builder/.buildkite-agent/builds/d12771cc4cec-1/llvm-project/libcxx-ci/build/generic-debug-iterators/test/std/algorithms/alg.sorting/alg.clamp/Output/ranges.clamp.pass.cpp.dir/t.tmp.exe
200 mslibcxx CI MacOS arm64 > llvm-libc++-shared-cfg-in.std/algorithms/alg_sorting/alg_clamp::ranges.clamp.pass.cpp
Script: -- : 'COMPILED WITH'; /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/static-162-255-21-37-macminivault-com/llvm-project/libcxx-ci/libcxx/test/std/algorithms/alg.sorting/alg.clamp/ranges.clamp.pass.cpp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk --target=arm64-apple-darwin21.4.0 -nostdinc++ -I /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/static-162-255-21-37-macminivault-com/llvm-project/libcxx-ci/build/generic-cxx20/include/c++/v1 -I /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/static-162-255-21-37-macminivault-com/llvm-project/libcxx-ci/build/generic-cxx20/include/c++/v1 -I /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/static-162-255-21-37-macminivault-com/llvm-project/libcxx-ci/libcxx/test/support -std=c++20 -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -lc++experimental -nostdlib++ -L /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/static-162-255-21-37-macminivault-com/llvm-project/libcxx-ci/build/generic-cxx20/lib -Wl,-rpath,/Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/static-162-255-21-37-macminivault-com/llvm-project/libcxx-ci/build/generic-cxx20/lib -lc++ -pthread -o /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/static-162-255-21-37-macminivault-com/llvm-project/libcxx-ci/build/generic-cxx20/test/std/algorithms/alg.sorting/alg.clamp/Output/ranges.clamp.pass.cpp.dir/t.tmp.exe
860 mslibcxx CI MacOS x86_64 > llvm-libc++-shared-cfg-in.std/algorithms/alg_sorting/alg_clamp::ranges.clamp.pass.cpp
Script: -- : 'COMPILED WITH'; /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/y10-8-macminivault-com/llvm-project/libcxx-ci/libcxx/test/std/algorithms/alg.sorting/alg.clamp/ranges.clamp.pass.cpp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk --target=x86_64-apple-darwin21.3.0 -nostdinc++ -I /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/y10-8-macminivault-com/llvm-project/libcxx-ci/build/generic-cxx20/include/c++/v1 -I /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/y10-8-macminivault-com/llvm-project/libcxx-ci/build/generic-cxx20/include/c++/v1 -I /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/y10-8-macminivault-com/llvm-project/libcxx-ci/libcxx/test/support -std=c++20 -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -lc++experimental -nostdlib++ -L /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/y10-8-macminivault-com/llvm-project/libcxx-ci/build/generic-cxx20/lib -Wl,-rpath,/Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/y10-8-macminivault-com/llvm-project/libcxx-ci/build/generic-cxx20/lib -lc++ -pthread -o /Users/libcxx-buildkite-agent/libcxx.buildkite-agent/builds/y10-8-macminivault-com/llvm-project/libcxx-ci/build/generic-cxx20/test/std/algorithms/alg.sorting/alg.clamp/Output/ranges.clamp.pass.cpp.dir/t.tmp.exe

Event Timeline

philnik created this revision.May 23 2022, 4:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2022, 4:33 AM
Herald added a subscriber: mgorny. · View Herald Transcript
philnik requested review of this revision.May 23 2022, 4:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2022, 4:33 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
var-const added inline comments.May 23 2022, 8:27 PM
libcxx/docs/Status/RangesAlgorithms.csv
35

Please don't forget to update the link before merging.

libcxx/test/std/algorithms/alg.sorting/alg.clamp/ranges.clamp.pass.cpp
23

Can you also check SFINAE with indirect_­strict_­weak_­order?

32

Ultranit: maybe use different values in different test cases? I know it sounds funny but I'm slightly concerned that return 20; would pass most if not all the tests. :) It might also make it a bit more obvious which value is being returned (high/low/original) when the same value of 20 doesn't have different meanings in different test cases.

38

Can you also check with a comparator that returns something convertible to bool?

40

Can you also add test cases like (10, 10, 20) and (10, 20, 20), i.e., when value is equal to one of the bounds but not the other?