C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Specify the mangled name

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 03 Feb 2025 09:20:00 -0800
On Monday 3 February 2025 09:10:33 Pacific Standard Time Andrey Semashev via
Std-Proposals wrote:
> > It would, except you can't get one because it's a Standard Library type.
> > Only the Standard Library can provide those and it doesn't.
>
> Does adding a forward declaration for a standard library component count
> as "adding something to namespace std", which is forbidden by the standard?

Probably. Either way, it *won't* work if the type in question is in an inline
namespace (libc++ is often in std::__1, libstdc++'s chrono types are in
std::_V2) or 'using'ed into the std namespace. You have to know the details
of the Standard Library in question to know how to declare the container and
the defaults.

> With some effort, it is possible to add forward declarations for
> standard library components for specific standard library
> implementations, and it works quite well in practice. For other unknown
> implementations you would just include the proper standard library header.

Aye. You *can* carry the basketball during a game, so long as the umpire
doesn't see it.

> > A <containerfwd> header would be very helpful.
>
> True, though I would prefer distinct headers like <set_fwd>,
> <vector_fwd>, etc.

Would work for us too.

We've just had this discussion in Qt because we wanted to add QDebug streaming
operators for the Standard Library containers, but as a result qdebug.h
includes over half of the Standard Library headers.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2025-02-03 17:20:07