Date: Tue, 4 Feb 2025 12:23:45 +0000
This isn't exactly crazy.
I'm currently working on this in order to be able to forward declare, not just any class, but any type.
you would just do something like:
typename MyType;
But this is not easy to implement because of type aliasing and name mangling, it would require breaking how libraries currently work, and add an extension in order to resolve aliased names at link time.
I haven't quite worked out the feasibility of this without having to invent a whole new way of code generation.
It would be useful if we were re-inventing C++ from scratch.
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]>
Sent: Tuesday, February 4, 2025 12:19:01 PM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Subject: Re: [std-proposals] Specify the mangled name
On Mon, Feb 3, 2025 at 3:52 PM Thiago Macieira wrote:
>
> A <containerfwd> header would be very helpful.
If we have the power to change the Standard so that there's a way of
forward-declaring standard library classes, then perhaps make it so
that we can do the following:
declare std::vector;
extern std::vector<int> &Func(void); // defined in another
translation unit
int main(void)
{
std::vector<int> &my_container = Func();
}
The new core language feature, "declare", must always be followed by
the name of a standard library class (or template class).
When a compiler encounters "declare", it basically just copy-pastes a
declaration in place. So the first time the following is encountered
in a translation unit:
declare std::vector;
it simply gets replaced with:
namespace std {
template<class T> class less;
template<class T> class allocator;
template< class Key, class Compare = less<Key>, class
Allocator = allocator<Key> > class set;
}
--
Std-Proposals mailing list
Std-Proposals_at_lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
I'm currently working on this in order to be able to forward declare, not just any class, but any type.
you would just do something like:
typename MyType;
But this is not easy to implement because of type aliasing and name mangling, it would require breaking how libraries currently work, and add an extension in order to resolve aliased names at link time.
I haven't quite worked out the feasibility of this without having to invent a whole new way of code generation.
It would be useful if we were re-inventing C++ from scratch.
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]>
Sent: Tuesday, February 4, 2025 12:19:01 PM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Subject: Re: [std-proposals] Specify the mangled name
On Mon, Feb 3, 2025 at 3:52 PM Thiago Macieira wrote:
>
> A <containerfwd> header would be very helpful.
If we have the power to change the Standard so that there's a way of
forward-declaring standard library classes, then perhaps make it so
that we can do the following:
declare std::vector;
extern std::vector<int> &Func(void); // defined in another
translation unit
int main(void)
{
std::vector<int> &my_container = Func();
}
The new core language feature, "declare", must always be followed by
the name of a standard library class (or template class).
When a compiler encounters "declare", it basically just copy-pastes a
declaration in place. So the first time the following is encountered
in a translation unit:
declare std::vector;
it simply gets replaced with:
namespace std {
template<class T> class less;
template<class T> class allocator;
template< class Key, class Compare = less<Key>, class
Allocator = allocator<Key> > class set;
}
--
Std-Proposals mailing list
Std-Proposals_at_lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-02-04 12:23:49