From e15dcdef212f2581083567c782557856fdf02410 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Sun, 22 Sep 2024 21:05:33 -0700 Subject: [PATCH] feat: ufcs ranges sort example --- examples/ufcs-ranges-sort/.gitignore | 2 ++ examples/ufcs-ranges-sort/build.cpp2 | 4 ++++ examples/ufcs-ranges-sort/ufcs-ranges-sort.cpp2 | 10 ++++++++++ 3 files changed, 16 insertions(+) create mode 100644 examples/ufcs-ranges-sort/.gitignore create mode 100644 examples/ufcs-ranges-sort/build.cpp2 create mode 100644 examples/ufcs-ranges-sort/ufcs-ranges-sort.cpp2 diff --git a/examples/ufcs-ranges-sort/.gitignore b/examples/ufcs-ranges-sort/.gitignore new file mode 100644 index 0000000..e54e919 --- /dev/null +++ b/examples/ufcs-ranges-sort/.gitignore @@ -0,0 +1,2 @@ +# cpp2b cache directory +.cache/cpp2 diff --git a/examples/ufcs-ranges-sort/build.cpp2 b/examples/ufcs-ranges-sort/build.cpp2 new file mode 100644 index 0000000..3fa0eb6 --- /dev/null +++ b/examples/ufcs-ranges-sort/build.cpp2 @@ -0,0 +1,4 @@ +import cpp2b.build; + +build: (inout b: cpp2b::build) -> void = { +} diff --git a/examples/ufcs-ranges-sort/ufcs-ranges-sort.cpp2 b/examples/ufcs-ranges-sort/ufcs-ranges-sort.cpp2 new file mode 100644 index 0000000..04b30f2 --- /dev/null +++ b/examples/ufcs-ranges-sort/ufcs-ranges-sort.cpp2 @@ -0,0 +1,10 @@ +main: () = { + a: std::array = (3, 1, 2); + a.std::ranges::sort(); + for a do (n) { + std::println("{}", n); + } + assert(a[0] == 1); + assert(a[1] == 2); + assert(a[2] == 3); +}