Date: Tue, 4 Feb 2025 11:19:01 +0000
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;
}
>
> 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;
}
Received on 2025-02-04 11:19:08