CWG Issue 2443 (original) (raw)

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

2025-11-05


2443. Meaningless template exports

Section: 10.2 [module.interface]Status: C++23Submitter: Davis HerringDate: 2019-11-09Liaison: EWG

[Accepted as a DR at the November, 2022 meeting, as part of paper P2615R1 (Meaningful exports).]

According to 10.2 [module.interface] paragraph 1, export does not interfere with other definitions; paragraph 3 merely requires that it appear in a declaration that declares at least one name. 13.1 [temp.pre] paragraph 4 prevents using an export-declaration as the declaration of a_template-declaration_.

With some interpretation, these rules appear to allow various useless constructs like:

template export void f(); export template void f(); export template<> void g(int); template<> export void g(int); export template struct trait<T*>;

Simply forbidding them in 10.2 [module.interface] paragraph 3 would also prohibit their appearance in export blocks:

export { template struct A; template struct A<T*>; }

It is already the case that the closely-related example

export { template struct A {A(non_deducible);}; template A(U) -> A<find_param>; }

is disallowed, although a fix is pending in EWG.

Suggested resolution: Forbid the direct use of theexport keyword in these contexts but continue to allow them (and perhaps more) in export { }.

Notes from the February, 2021 teleconference:

CWG agreed with the suggested direction.

Notes from the 2022-05-20 CWG telecon:

CWG agreed with the wording suggested by Herring; forwarding to EWG for approval.