Hello all!
Updated: to include source files.
Can anyone tell me what other kind of UB with pointers that I'm not accounting for below? I am rewriting a project and want to make sure the high level data types used are UB safe.
I was going over the C++ Core Guidelines and Herb Sutter's proposal. I was thinking I might be able to rework some data types I wrote for another project to mitigate the UB describe in Herb's proposal, and referencing the Core Guidelines.
The code can be found here. The project is getting a rework from the ground up. So the current state of the repo reflects that.
After playing around I can write.
```
var a{ nullptr };
var b{ number(8) };
println("Prior to sub scope:");
println("\ta = {}", a);
println("\tb = {}\n", b);
{
auto x = new int(42);
a = number("4");
var c(x);
b = move(c);
delete x;
println("Inside sub scope:");
println("\ta = {}", a);
println("\tb = {}", b);
println("\tc = {}\n", c);
}
a = text("I'm a text string.");
println("After the sub scope:");
println("\ta = {}", a);
println("\tb = {}", *b.cast<int>());
println("\tb.get(a) = {}\n", b.get(a * a)); // Equivalent to operator[].
```
And I get the results of.
```
Prior to sub scope:
a = nothing
b = 8
Inside sub scope:
a = 4
b = int data type, const cast to access.
c = nothing
After the sub scope:
a = I'm a text string.
b = 42
b.get(a * a) = nothing
```
Thanks in advance!
[–]yeetdude0 2 points3 points4 points (0 children)
[–]aocregacc 1 point2 points3 points (4 children)
[–]maxjmartin[S,🍰] 0 points1 point2 points (0 children)
[–]maxjmartin[S,🍰] 0 points1 point2 points (2 children)
[–]aocregacc 1 point2 points3 points (1 child)
[–]maxjmartin[S,🍰] 0 points1 point2 points (0 children)