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

2024-12-06


1682. Overly-restrictive rules on function templates as allocation functions

Section: 6.7.5.5.2  [basic.stc.dynamic.allocation]     Status: open     Submitter: Jason Merrill     Date: 2009-03-03

Requirements for allocation functions are given in 6.7.5.5.2 [basic.stc.dynamic.allocation] paragraph 1:

An allocation function can be a function template. Such a template shall declare its return type and first parameter as specified above (that is, template parameter types shall not be used in the return type and first parameter type). Template allocation functions shall have two or more parameters.

There are a couple of problems with this description. First, it is instances of function templates that can be allocation functions, not the templates themselves (cf 6.7.5.5.3 [basic.stc.dynamic.deallocation] paragraph 2, which uses the correct terminology regarding deallocation functions).

More importantly, this specification was written before template metaprogramming was understood and hence prevents use of SFINAE on the return type or parameter type to select among function template specializations. (The parallel passage for deallocation functions in 6.7.5.5.3 [basic.stc.dynamic.deallocation] paragraph 2 shares this deficit.)

(See also issue 1628.)