A RetroSearch Logo

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

Search Query:

Showing content from https://cplusplus.github.io/CWG/issues/2018.html below:

CWG Issue 2018

This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-08-11

2018. Qualification conversion vs reference bindingSection: 9.5.4  [dcl.init.ref]     Status: dup     Submitter: Richard Smith     Date: 2014-10-07

Qualification conversions are not considered when doing reference binding, which leads to some unexpected results:

  template<typename T> T make();
  struct B {}; struct D : B {};

  const int *p1 = make<int*>();           // ok, qualification conversion
  const int *const *p2 = make<int**>();   // ok, qualification conversion
  const int **p3 = make<int**>();         // error, not type safe

  const int &r1 = make<int&>();           // ok, binds directly
  const int *const &r2 = make<int*&>();   // weird, binds to a temporary
  const int *&r3 = make<int*&>();         // error

  const int &&x1 = make<int&&>();         // ok, binds directly
  const int *const &&x2 = make<int*&&>(); // weird, binds to a temporary
  const int *&&x3 = make<int*&&>();       // weird, binds to a temporary

It might make sense to say that similar types are reference-related and if there is a qualification conversion they are reference-compatible.

See also issue 2023.

Rationale (September, 2023):

This issue is a duplicate of issue 2352.


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