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); +}