A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.github.io/LWG/issue2161 below:

Issue 2161: const equivalence of std::map

This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.

2161. const equivalence of std::map

Section: 23.4 [associative], 23.5 [unord] Status: NAD Submitter: Bjarne Stroustrup Opened: 2012-06-18 Last modified: 2016-08-02

Priority: 2

View all other issues in [associative].

View all issues with NAD status.

Discussion:

As described in the reflector discussion c++std-core-21860 consider the following example:

map<const int, int> mci{};
map<int, int> mi = mci; // ??
mci[1] = 2;
mi[1] = 2;

Should it be required that the marked initialization is well-formed? As a possible solution this could be realized by an alias template:

template <class K, class T>
struct OriginalMap { […] };

template <class K, class T>
using ImprovedMap = OriginalMap<const K, T>;

[2016-08 Chicago]

Recommend NAD. No other container supports conversion from different container specializations, so adding support directly might be more surprising than the omission.

We would welcome papers on the convertibility of containers of different element types directed to the LEWG in the future.

Proposed resolution:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4