I feel like C++ currently has a slight problem with its type system. Whenever we use either typedef or using to declare a symbol, it’s only an alias, it isn’t treated as it’s own type. The main problem with this is function overloading. I could imagine some code akin to the following:
let Foo = SomeSuperLongTypeName<i32>
let Bar = SomeSuperLongTypeName<i32>
function do_stuff_with(foo: Foo) {
return “result of doing stuff with Foo”
}
function do_stuff_with(bar: Bar) {
return “result of doing stuff with Bar”
}
function main() {
let foo = Foo()
let bar = Bar()
let a = do_stuff_with(foo)
let b = do_stuff_with(bar)
}
If the types Foo
and Bar
were aliases and not copies of SomeSuperLongTypeName<i32>
, this code would be ambiguous. So I’d like to propose keywords for aliasing/copying types. Perhaps we could use alias
and type
where alias
would be treated like a simple name substitution and type
would copy the type definition. Alternatively maybe we could use let
for the type definition copy.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too