Skip to content

Commit 67b1022

Browse files
authored
add yandere-chan.binary_tree 0.1.4 (#848)
* add YandereChan2.binary_tree 0.1.0 Form A package: the tag tarball carries the library's own mcpp.toml, which declares the header library and the C++23 module wrappers (binary_tree, Yc.intrusive_binary_tree, Yc.binary_tree, Yc.parent_aware_binary_tree). Adds tests/examples/binary_tree-module, which imports the lib root and every wrapper and asserts owning/intrusive tree behavior. * binary_tree: update to 0.1.2 (libc++ <new> order) 0.1.0 and 0.1.1 fail a libc++ module consumer because placement new is not declared when allocator_traits is parsed. 0.1.2 includes <new> before <memory> in the owning headers and in the module GMF. Update the descriptor, the test member dependency and the plan. * binary_tree: rename namespace to yandere-chan, 0.1.3 Use the lowercase hyphenated namespace yandere-chan for the package identity and the index file. Move to 0.1.3, which carries the same libc++ <new> fix under the new namespace; 0.1.0-0.1.2 stay unlisted. * binary_tree test: include <new> for libc++ libc++'s allocator_traits::construct instantiates __construct_at with a placement-new default argument in the importer's context; the module GMF <new> is not reachable from an importer. Include <new> before the imports in the consumer (no-op on MSVC STL/libstdc++) and correct the design note. * binary_tree: 0.1.4 exports operator new/delete clang's combined -fmodule-output build does not make the module GMF <new> visible to importers, so libc++ consumers instantiating allocator_traits::construct needed #include <new>. The three module interfaces now export using ::operator new/::operator delete; both tests build without <new>, including an umbrella-only test. Update the descriptor to 0.1.4 and the plan.
1 parent ee3ad26 commit 67b1022

6 files changed

Lines changed: 301 additions & 0 deletions

File tree

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Add yandere-chan.binary_tree 0.1.4
2+
3+
## Source and shape
4+
5+
- Upstream: <https://github.com/YandereChan2/binary_tree>.
6+
- Version: `0.1.4`, tagged on the commit that exports the global
7+
`operator new` / `operator delete` using-declarations from the module
8+
interfaces (namespace `yandere-chan` was introduced in 0.1.3).
9+
- License: MIT.
10+
- Shape: Form A (mcpp-native library). The tarball carries
11+
`binary_tree-0.1.4/mcpp.toml`; that manifest is the build. It declares:
12+
- `include_dirs = ["."]` — the header library (`binary_tree.h`,
13+
`parent_aware_binary_tree.h`, `intrusive_binary_tree.h`, `union_data.h`,
14+
and the POC sets) stays a normal header interface;
15+
- sources `Yc.intrusive_binary_tree.cppm`, `Yc.binary_tree.cppm`,
16+
`Yc.parent_aware_binary_tree.cppm` and `src/binary_tree.cppm`;
17+
- `[lib] path = "src/binary_tree.cppm"` — the lib root re-exports the three
18+
wrappers, so `import binary_tree;` reaches all of them and `mcpp pack` has
19+
a module interface to publish.
20+
- No features and no dependencies: the library is header/module only.
21+
22+
The four public modules are `binary_tree`, `Yc.intrusive_binary_tree`,
23+
`Yc.binary_tree` and `Yc.parent_aware_binary_tree`; module names are
24+
independent of the package namespace.
25+
26+
## The libc++ placement-new problem and the export fix
27+
28+
The Linux LLVM run (clang + libc++) failed on 0.1.0 with:
29+
30+
```
31+
libc++ __memory/allocator_traits.h:362: error: no matching function for call to '__construct_at'
32+
construct_at.h:43: ... no matching 'operator new' function
33+
for non-allocating placement new expression; include <new>
34+
```
35+
36+
`std::allocator_traits::construct` instantiates libc++'s `__construct_at`,
37+
whose default template argument uses placement new. Adding `<new>` to the
38+
module's global module fragment is not enough: clang's combined
39+
single-invocation module build (`-x c++-module -fmodule-output=... -c`, the
40+
mode mcpp uses) does not make the GMF declaration **visible** to the importer,
41+
even though it is reachable. The lookup happens when the consumer instantiates
42+
the template, so `import binary_tree;` alone failed. See
43+
llvm/llvm-project#218246 (and the earlier #59601), which lists the same two
44+
workarounds: instantiate in the defining module, or re-declare the missing
45+
declaration in the importing TU.
46+
47+
0.1.4 takes a third route that keeps the consumer clean: each module interface
48+
exports a using-declaration for the global placement `operator new` and its
49+
matching `operator delete`:
50+
51+
```cpp
52+
export module Yc.binary_tree;
53+
54+
import Yc.intrusive_binary_tree;
55+
56+
export using ::operator new;
57+
export using ::operator delete;
58+
```
59+
60+
The using-declarations are exported names (not declarations of new entities),
61+
so an importer can look placement new up without including `<new>`, and a
62+
consumer that *does* include `<new>` still compiles. The declarations must
63+
come after the imports: GCC requires post-module imports to be contiguous.
64+
Clang, MSVC and GCC 16.1 all accept the form; the umbrella module re-exports
65+
it through `export import`.
66+
67+
0.1.0-0.1.3 are not listed: all carry the old `YandereChan2` namespace and
68+
predate this export.
69+
70+
## Download and mirror
71+
72+
- GLOBAL:
73+
`https://github.com/YandereChan2/binary_tree/releases/download/0.1.4/binary_tree-0.1.4.tar.gz`
74+
(a `git archive` of tag `0.1.4`, uploaded as the release asset; the tarball
75+
root is `binary_tree-0.1.4/`)
76+
- SHA-256:
77+
`e7bd88adaa156219d87db05cbe4bc0dd5447ee7c7736f138f0870ebdfa706853`
78+
- No `mcpp-res` mirror is available, so the descriptor uses the repository's
79+
plain-string upstream URL fallback. No CN mirror is invented; a maintainer
80+
can add a byte-identical GitCode release later.
81+
- `extensions.autoupdate` uses the bare tag and the tag-archive template
82+
(`archive/refs/tags/${tag}.tar.gz`), so a future release needs no uploaded
83+
asset for the updater to compute its sha.
84+
85+
## Test member
86+
87+
- `tests/examples/binary_tree-module/` has two test files:
88+
- `binary_tree_module.cpp` imports the lib root and each wrapper and asserts
89+
insert / in-order `for_each` / copy / `parent_of_cnroot` / intrusive-node
90+
behavior;
91+
- `binary_tree_umbrella.cpp` imports only `binary_tree` (umbrella-only) and
92+
asserts the same construction path, which proves the re-exported
93+
placement-new declarations reach an importer that never includes `<new>`.
94+
95+
Neither file includes `<new>` or any library header. Every check affects the
96+
process exit status.
97+
- The member carries its own
98+
`[indices] yandere-chan = { path = "../../.." }` so the dependency resolves
99+
to the checked-in descriptor rather than the published remote index.
100+
101+
## Verification
102+
103+
- Pinned mcpp `2026.11.18.1`, the version in `validate.yml`:
104+
`mcpp xpkg parse pkgs/y/yandere-chan.binary_tree.lua` reports `parse OK`
105+
for linux, macosx and windows, and recognizes Form A.
106+
- `mcpp test -p binary_tree-module --cache off` downloads the 0.1.4 asset,
107+
compiles both tests without `<new>`, and both pass.
108+
- The same manifest builds with `mcpp build` (clang + MSVC STL),
109+
`mcpp build --toolchain msvc@system`; all four `.cppm` compile with GCC
110+
16.1 (`-fmodules`).
111+
- A minimal clang 23.1.3 combined-mode repro of the placement-new bug
112+
(`module; #include <new>` + direct placement new) fails without the export
113+
and passes with it; MSVC 14.51 and GCC 16.1 accept the exported form.
114+
115+
## Notes
116+
117+
- The export is a workaround for the clang module bug, not a permanent API
118+
requirement. If a future clang makes GMF scopes visible to importers, the
119+
using-declarations can be dropped.
120+
- The POC set headers `rb_set.h` / `avl_set.h` import
121+
`parent_aware_binary_tree.h` as a header unit on MSVC; that path is not part
122+
of this package.
123+
- The package is platform-independent: the same tarball and sha are used for
124+
linux, macosx and windows.

‎mcpp.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ members = [
6565
"tests/examples/accesskit",
6666
"tests/examples/asio-module",
6767
"tests/examples/asio-ssl",
68+
"tests/examples/binary_tree-module",
6869
"tests/examples/boost-asio",
6970
"tests/examples/boost-any",
7071
"tests/examples/boost-circular-buffer",
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
-- yandere-chan.binary_tree — Intrusive and owning binary tree library with
2+
-- C++23 module wrappers.
3+
--
4+
-- Form A: the release tarball carries the package's own `mcpp.toml` at its
5+
-- root (`binary_tree-<version>/mcpp.toml`), and that manifest is the build: it
6+
-- declares the header library (`include_dirs = ["."]`), the three module
7+
-- wrappers `Yc.intrusive_binary_tree` / `Yc.binary_tree` /
8+
-- `Yc.parent_aware_binary_tree`, and the lib root `src/binary_tree.cppm` that
9+
-- re-exports them for `import binary_tree;`. The `mcpp` field is therefore the
10+
-- wrapper-directory pointer, not an inline Form B descriptor.
11+
--
12+
-- 0.1.4 is `git archive` of the tag, uploaded as a release asset. Besides the
13+
-- `yandere-chan` namespace it exports the global `operator new` / `operator
14+
-- delete` using-declarations from all three module interfaces, so a libc++
15+
-- consumer does not need `#include <new>`: clang's combined `-fmodule-output`
16+
-- build does not make the module's GMF `<new>` visible to importers, and
17+
-- libc++'s `allocator_traits::construct` looks placement new up at
18+
-- instantiation (llvm/llvm-project#218246).
19+
--
20+
-- 0.1.0-0.1.3 are intentionally not listed: all four carry the old
21+
-- `YandereChan2` namespace, and 0.1.0-0.1.3 predate the exported
22+
-- `operator new`/`operator delete` declarations.
23+
--
24+
-- Upstream tags are bare versions (`0.1.4`), so the xpm key carries the tag
25+
-- verbatim and autoupdate's tag pattern is `${version}`.
26+
--
27+
-- No mcpp-res mirror is configured yet (no CN access): the plain-string GLOBAL
28+
-- url is the documented fallback for CN consumers until a maintainer creates
29+
-- the mirror.
30+
package = {
31+
spec = "1",
32+
namespace = "yandere-chan",
33+
name = "binary_tree",
34+
description = "Intrusive and owning binary tree library, with C++23 module wrappers",
35+
licenses = {"MIT"},
36+
repo = "https://github.com/YandereChan2/binary_tree",
37+
type = "package",
38+
maintainers = {"YandereChan2"},
39+
40+
extensions = {
41+
autoupdate = {
42+
tag = "${version}",
43+
url = "https://github.com/YandereChan2/binary_tree/archive/refs/tags/${tag}.tar.gz",
44+
},
45+
},
46+
47+
xpm = {
48+
linux = {
49+
["0.1.4"] = {
50+
url = "https://github.com/YandereChan2/binary_tree/releases/download/0.1.4/binary_tree-0.1.4.tar.gz",
51+
sha256 = "e7bd88adaa156219d87db05cbe4bc0dd5447ee7c7736f138f0870ebdfa706853",
52+
},
53+
},
54+
macosx = {
55+
["0.1.4"] = {
56+
url = "https://github.com/YandereChan2/binary_tree/releases/download/0.1.4/binary_tree-0.1.4.tar.gz",
57+
sha256 = "e7bd88adaa156219d87db05cbe4bc0dd5447ee7c7736f138f0870ebdfa706853",
58+
},
59+
},
60+
windows = {
61+
["0.1.4"] = {
62+
url = "https://github.com/YandereChan2/binary_tree/releases/download/0.1.4/binary_tree-0.1.4.tar.gz",
63+
sha256 = "e7bd88adaa156219d87db05cbe4bc0dd5447ee7c7736f138f0870ebdfa706853",
64+
},
65+
},
66+
},
67+
68+
mcpp = "*/mcpp.toml",
69+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# binary_tree module-package test: consumes yandere-chan.binary_tree by import
2+
# only and asserts behavior under `mcpp test`.
3+
#
4+
# This member is the only place the descriptor's Form A lookup is exercised:
5+
# `[indices]` below overrides the workspace-root `compat` redirect, so
6+
# yandere-chan resolves to this checkout (pkgs/y/yandere-chan.binary_tree.lua)
7+
# rather than the published remote index. The key is the dependency NAMESPACE.
8+
[indices]
9+
yandere-chan = { path = "../../.." }
10+
11+
[package]
12+
name = "binary_tree-module-tests"
13+
version = "0.1.0"
14+
15+
# The package is the mcpp-native library: its own tarball carries mcpp.toml,
16+
# which declares the public modules below. Import the umbrella root and each
17+
# wrapper so a regression in either surface fails this member. The umbrella
18+
# test also checks the exported placement-new declarations (no <new> include
19+
# anywhere in the consumer), which is what libc++ needs under clang's
20+
# combined module build (llvm/llvm-project#218246).
21+
#
22+
# 0.1.4 is the first release with the `yandere-chan` namespace and the exported
23+
# `operator new`/`operator delete`; earlier versions are not listed.
24+
[dependencies.yandere-chan]
25+
binary_tree = "0.1.4"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// yandere-chan.binary_tree module-package end-to-end assertion: consume the
2+
// library by import only (no `#include` of its headers, no include path setup).
3+
//
4+
// * `import binary_tree;` — the lib root, re-exporting all three
5+
// * `import Yc.binary_tree;` — owning, no parent pointer
6+
// * `import Yc.parent_aware_binary_tree;` — owning, with parent pointers
7+
// * `import Yc.intrusive_binary_tree;` — intrusive node hooks
8+
//
9+
// Every check increments `failures`; the process exits non-zero when a check
10+
// does not hold, which is what makes this a test rather than a sample.
11+
12+
import Yc.intrusive_binary_tree;
13+
import Yc.binary_tree;
14+
import Yc.parent_aware_binary_tree;
15+
import binary_tree;
16+
17+
int main()
18+
{
19+
int failures = 0;
20+
auto check = [&failures](bool ok) { if (!ok) { ++failures; } };
21+
22+
// Owning tree without parent pointers.
23+
Yc::binary_tree<int> t;
24+
t.insert(t.root(), 1);
25+
t.insert(t.root().get_left(), 2);
26+
t.insert(t.root().get_right(), 3);
27+
28+
check(!t.empty());
29+
check(*t.nroot() == 1);
30+
check(*t.root().get_left() == 2);
31+
check(*t.root().get_right() == 3);
32+
33+
int sum = 0;
34+
t.for_each([&sum](int& v) { sum += v; });
35+
check(sum == 6);
36+
37+
// Copy construction walks and copies the structure.
38+
Yc::binary_tree<int> copy = t;
39+
int copy_sum = 0;
40+
copy.for_each([&copy_sum](int& v) { copy_sum += v; });
41+
check(copy_sum == 6);
42+
43+
// Owning tree with parent pointers.
44+
Yc::parent_aware_binary_tree<int> p;
45+
p.insert(p.root(), 5);
46+
p.insert(p.root().get_left(), 6);
47+
48+
check(*p.nroot() == 5);
49+
check(*p.nroot().get_left() == 6);
50+
check(!p.parent_of_cnroot().null());
51+
52+
// Intrusive tree: the user node carries the hooks.
53+
struct node : Yc::intrusive_binary_tree_node_base<> { int value = 0; };
54+
Yc::basic_intrusive_binary_tree<> it;
55+
node a;
56+
a.value = 7;
57+
it.insert(it.root(), a);
58+
59+
check(!it.empty());
60+
check(static_cast<node&>(*it.nroot()).value == 7);
61+
62+
return failures == 0 ? 0 : 1;
63+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// yandere-chan.binary_tree umbrella-only assertion: import the lib root and
2+
// nothing else. This checks that `export import` re-exports both the owning
3+
// tree template and the placement-new declarations exported by the wrappers,
4+
// so no `#include <new>` is needed here either.
5+
6+
import binary_tree;
7+
8+
int main()
9+
{
10+
Yc::binary_tree<int> t;
11+
t.insert(t.root(), 1);
12+
t.insert(t.root().get_left(), 2);
13+
14+
if (t.empty() || *t.nroot() != 1 || *t.root().get_left() != 2) { return 1; }
15+
16+
int sum = 0;
17+
t.for_each([&sum](int& v) { sum += v; });
18+
return sum == 3 ? 0 : 1;
19+
}

0 commit comments

Comments
 (0)