C++ Logo

std-proposals

Advanced search

Re: [std-proposals] (no subject)

From: Simon Schröder <dr.simon.schroeder_at_[hidden]>
Date: Mon, 10 Nov 2025 07:03:17 +0100
Well, there is nothing directly in the language right now. And I don‘t think that it would be simple to include. However, it is possible to not use the whole namespace but to only use certain things from it. It might be cumbersome to write out the things every single time. Instead, you can create your own header that gets only certain symbols into a new namespace ‘memory’. Then you can decide to just get all symbols from ‘memory’ into your new namespace.

There are already a few things that are in their own subnamespaces (like placeholders or literals). We could think about changing the standard to make symbols available both in std and e.g. std::memory. Probably we should first think if we should use finer grained namespaces than header scope. I am personally annoyed with the namespaces std::ranges and std::views that don’t have the symbols in the std namespace directly.

On the other hand I feel like the general consensus is to not ‘using’ full namespaces (except for the few controlled namespaces like placeholders and literals). I don’t know if we should really support this kind of approach. I have learned C++ with ‘using namespace std’, but now I’ve come accustomed to explicitly prefix everything with std::.

Why do you want to be ‘using’ full namespaces against current common practice?

> On Nov 10, 2025, at 1:36 AM, Budi via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> 
> How can I code/write something, for illustration, sort of like:
> using namespace memory::std;
>
> for the need that:
> Only names from <memory> (like std::unique_ptr, std::shared_ptr, etc.) become visible, without bringing in the entire std namespace
> In other words; could allow using namespace std::memory; or similar syntax to only expose symbols from a specific header or subset of a namespace.
>
> That’s conceptually like “namespace submodules” or such
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-11-10 06:03:35