@cella-lang/cpp 0.1.202611151755 → 0.1.202611161215
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +34 -2
- package/cpp.arrays.cell +0 -0
- package/cpp.cell +0 -0
- package/cpp.classes.cell +0 -0
- package/cpp.classrules.cell +0 -0
- package/cpp.construction.cell +0 -0
- package/cpp.constructs.cell +0 -0
- package/cpp.copies.cell +0 -0
- package/cpp.exceptions.cell +0 -0
- package/cpp.friends.cell +0 -0
- package/cpp.inheritance.cell +0 -0
- package/cpp.lambdas.cell +0 -0
- package/cpp.layouts.cell +0 -0
- package/cpp.library.algorithms.cell +0 -0
- package/cpp.library.bitsets.cell +0 -0
- package/cpp.library.cell +0 -0
- package/cpp.library.comparisons.cell +0 -0
- package/cpp.library.deques.cell +0 -0
- package/cpp.library.iterators.cell +0 -0
- package/cpp.library.limits.cell +0 -0
- package/cpp.library.lists.cell +0 -0
- package/cpp.library.maps.cell +0 -0
- package/cpp.library.numerics.cell +0 -0
- package/cpp.library.pairs.cell +0 -0
- package/cpp.library.queues.cell +0 -0
- package/cpp.library.sets.cell +0 -0
- package/cpp.library.stacks.cell +0 -0
- package/cpp.library.streamiterators.cell +0 -0
- package/cpp.library.strings.cell +0 -0
- package/cpp.library.trees.cell +0 -0
- package/cpp.library.tuples.cell +0 -0
- package/cpp.library.unorderedmaps.cell +0 -0
- package/cpp.library.vectors.cell +0 -0
- package/cpp.memberpointers.cell +0 -0
- package/cpp.names.cell +0 -0
- package/cpp.objects.cell +0 -0
- package/cpp.operators.cell +0 -0
- package/cpp.overloading.cell +0 -0
- package/cpp.polymorphism.cell +0 -0
- package/cpp.primitives.cell +0 -0
- package/cpp.ranges.cell +0 -0
- package/cpp.references.cell +0 -0
- package/cpp.runtimetypes.cell +0 -0
- package/cpp.standardexceptions.cell +0 -0
- package/cpp.standardfunctions.cell +0 -0
- package/cpp.staticmembers.cell +0 -0
- package/cpp.streams.cell +0 -0
- package/cpp.templates.cell +0 -0
- package/cpp.userconversions.cell +0 -0
- package/index.json +1204 -1188
- package/package.json +6 -6
package/CHANGES.md
CHANGED
|
@@ -5,6 +5,39 @@
|
|
|
5
5
|
|
|
6
6
|
## 未發佈
|
|
7
7
|
|
|
8
|
+
- **有引數的 constexpr 建構子:用常數建構的全域物件是常數初始化**([basic.start.static]p2、[expr.const]p2、[dcl.constexpr]p3):
|
|
9
|
+
之前 `struct P { int v; constexpr P(int a) : v(a) {} }; P p(3);` 的 `p` 在原來的位置建構,寫在前面的動態初始化讀它判 reject,clang
|
|
10
|
+
讀到 3。現在全域物件用 `P p(3)`、`P p = P(3)`、`P p{3}` 建構、引數只由字面常數與寫在前面可以用在常數運算式裡的 const 整數組成,
|
|
11
|
+
而且這個引數個數可能選到的建構子都是常數的(constexpr、本體是空的、參數是純量、每個成員用參數與字面常數的運算式初始化一次,
|
|
12
|
+
或用字面常數的預設成員初始值;類別沒有基底、虛擬函式,成員都是純量)時,在任何動態初始化之前建構;有解構子的照建構完成的順序解構。
|
|
13
|
+
其餘的照舊在原來的位置建構(建構子不是 constexpr、引數讀到不是常數的變數:寫在前面的動態初始化讀它照舊判 reject)。轉換工具從
|
|
14
|
+
clang 的 AST 填 `mbCtor` 的 `constexpr`。新欄位 `ClassMembers.constantArities`、`DeclaredConstructor.constexpr`(**不相容**:自己列
|
|
15
|
+
全部欄位的記錄要補);`Classes.constantObject` 多一個參數 `usable`(**不相容**,內部名字);新的內部名字:
|
|
16
|
+
`Classes.constantAritiesOf`、`Classes.constantConstructor`、`Classes.constantItem`、`Classes.fromParameters`。所有函式庫模組與案例模組重新產生
|
|
17
|
+
(`mbCtor` 多一個欄位,雜湊改變)。測試:`tests/cases/static_initialization/`(多 3 支,共 13 支;`constexpr_constructor_early.cpp`
|
|
18
|
+
印 `3 8 6 7 3 ~R8`,對過 clang++ -std=c++17)。
|
|
19
|
+
|
|
20
|
+
- **`std::deque` 的 `clear`、`std::remove`、`std::binary_search`**:之前模型的 `std::deque<int>` 沒有成員 `clear`,`<algorithm>`
|
|
21
|
+
沒有 `remove` 與 `binary_search`,用到的程式判 unknown(不支援)。現在 `d.clear()` 從前面依序解構每個元素、清空(保留區塊,同 libc++);
|
|
22
|
+
`std::deque` 也改成照 libc++ 分塊(元素放在固定大小的區塊,兩端放入時只加區塊、元素不再搬動):之前做成環狀緩衝,滿了把全部
|
|
23
|
+
元素移到兩倍大的緩衝,多出移動建構與解構(元素的解構子有輸出時多印,clang 不會),兩端放入之後之前拿到的元素參考也失效
|
|
24
|
+
([deque.modifiers]p1:兩端放入不讓參考失效)。
|
|
25
|
+
`remove(first, last, value)` 照 libc++:找到第一個相等的,之後不相等的依序移到前面,回傳新的結尾(erase-remove 的寫法
|
|
26
|
+
`v.erase(remove(v.begin(), v.end(), x), v.end())` 可以用);`binary_search(first, last, value[, comp])` 是 `lower_bound` 之後看找到的
|
|
27
|
+
是不是相等。沒給比較子的 `binary_search` 和 `lower_bound` 一樣先檢查範圍對 `e < value` 與 `!(value < e)` 分好([alg.binary.search]p1),
|
|
28
|
+
沒分好是前置條件違反,判 reject(libc++ 不檢查,編譯後的結果看運氣)。函式庫模組 `cpp.library.deques`、`cpp.library.algorithms`
|
|
29
|
+
重新產生(雜湊改變)。測試:`tests/cases/library_sequence_operations/`(7 支,在 VM 上跑;改前 6 支 unknown、`deque_reference_kept.cpp`
|
|
30
|
+
判 reject(參考失效),改後照 clang)。
|
|
31
|
+
|
|
32
|
+
- **例外離開 noexcept 的建構子會結束程式**([except.spec]p5、[except.terminate]p1):之前程式宣告的建構子降成函式時一律不是
|
|
33
|
+
noexcept,`T(int x) noexcept : v(x) { if (x < 0) throw 1; }` 丟出的例外被外面的 handler 接住,判 accept、印出 handler 的輸出(誤判;
|
|
34
|
+
clang 中止,結束碼 134)。現在宣告成 noexcept 的建構子與建構子樣板,例外離開它(本體或成員初始化)就和一般的 noexcept 函式一樣呼叫
|
|
35
|
+
`std::terminate`(問題種類 `uncaught`)。隱含的建構子不加:它只在呼叫的全都是 noexcept 時才是 noexcept,那些自己就會結束程式。
|
|
36
|
+
成員函式、靜態成員函式、使用者宣告的指定運算子與解構子(沒寫例外規格就是 noexcept)原本就照做,新測試一併固定。沒做:lambda 的
|
|
37
|
+
noexcept(語意樹的 `sLambda` 沒有這個欄位,`operator()` 一律不是 noexcept)。`Classes.constructor`、`Classes.constructorNamed`
|
|
38
|
+
多一個參數 `noexc: Bool`(**不相容**,內部名字)。測試:`tests/cases/noexcept_members/`(8 支,在 VM 上跑;建構子的 3 支改前 accept
|
|
39
|
+
並印 caught,改後照 clang)。
|
|
40
|
+
|
|
8
41
|
- **函式樣板的偏序只在可行的之間比**([over.match.viable]p3、[over.match.best]p2.5):推導不看沒有樣板參數的參數,`P` 與
|
|
9
42
|
`const char *` 的樣板對一個 string 也推導得出來;之前偏序在「推導得出來」的樣板之間挑最特化的,`const char *` 比 `const string &`
|
|
10
43
|
「更特化」,只留它當候選,結果沒有一個可行,判 reject "no matching function"(`u.replace(u.begin(), u.begin() + 1, string("zz"))`,
|
|
@@ -28,8 +61,7 @@
|
|
|
28
61
|
int x = y;` 的 `x` 被當成動態初始化(先是零),寫在前面的動態初始化讀到 0,clang 讀到 7。現在有解構子的類別物件(其餘條件同上一條)
|
|
29
62
|
也在任何動態初始化之前建構,解構的順序照它在動態初始化之間的位置(標準:照建構完成的順序的反序);初始值只讀到寫在前面、本身是
|
|
30
63
|
常數初始化的 const 整數或列舉的全域變數,也是常數初始化。clang 的輸出對過(`destructor_constant_early.cpp` 印 `5 ~E2~D5~E1`、
|
|
31
|
-
`const_read_early.cpp` 印 `70660
|
|
32
|
-
constexpr,這種物件照舊在原來的位置建構,寫在前面的動態初始化讀它判 reject(clang 讀到建構好的值);要語意樹加標記。
|
|
64
|
+
`const_read_early.cpp` 印 `70660`)。有引數的 constexpr 建構子見上面一條。
|
|
33
65
|
測試:`tests/cases/static_initialization/`(多 2 支,共 10 支)。
|
|
34
66
|
|
|
35
67
|
- **全域的類別物件:隱含的預設建構子是常數運算式時是常數初始化**([basic.start.static]p2、[class.default.ctor]p4):`struct Q { int v = 5; };
|
package/cpp.arrays.cell
CHANGED
|
Binary file
|
package/cpp.cell
CHANGED
|
Binary file
|
package/cpp.classes.cell
CHANGED
|
Binary file
|
package/cpp.classrules.cell
CHANGED
|
Binary file
|
package/cpp.construction.cell
CHANGED
|
Binary file
|
package/cpp.constructs.cell
CHANGED
|
Binary file
|
package/cpp.copies.cell
CHANGED
|
Binary file
|
package/cpp.exceptions.cell
CHANGED
|
Binary file
|
package/cpp.friends.cell
CHANGED
|
Binary file
|
package/cpp.inheritance.cell
CHANGED
|
Binary file
|
package/cpp.lambdas.cell
CHANGED
|
Binary file
|
package/cpp.layouts.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.bitsets.cell
CHANGED
|
Binary file
|
package/cpp.library.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.deques.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.limits.cell
CHANGED
|
Binary file
|
package/cpp.library.lists.cell
CHANGED
|
Binary file
|
package/cpp.library.maps.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.pairs.cell
CHANGED
|
Binary file
|
package/cpp.library.queues.cell
CHANGED
|
Binary file
|
package/cpp.library.sets.cell
CHANGED
|
Binary file
|
package/cpp.library.stacks.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.strings.cell
CHANGED
|
Binary file
|
package/cpp.library.trees.cell
CHANGED
|
Binary file
|
package/cpp.library.tuples.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.vectors.cell
CHANGED
|
Binary file
|
package/cpp.memberpointers.cell
CHANGED
|
Binary file
|
package/cpp.names.cell
CHANGED
|
Binary file
|
package/cpp.objects.cell
CHANGED
|
Binary file
|
package/cpp.operators.cell
CHANGED
|
Binary file
|
package/cpp.overloading.cell
CHANGED
|
Binary file
|
package/cpp.polymorphism.cell
CHANGED
|
Binary file
|
package/cpp.primitives.cell
CHANGED
|
Binary file
|
package/cpp.ranges.cell
CHANGED
|
Binary file
|
package/cpp.references.cell
CHANGED
|
Binary file
|
package/cpp.runtimetypes.cell
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/cpp.staticmembers.cell
CHANGED
|
Binary file
|
package/cpp.streams.cell
CHANGED
|
Binary file
|
package/cpp.templates.cell
CHANGED
|
Binary file
|
package/cpp.userconversions.cell
CHANGED
|
Binary file
|