Title
Overly-restrictive rules on function templates as allocation functions
Status
open
Section
6.7.5.5.2 [basic.stc.dynamic.allocation]
Submitter
Jason Merrill

Created on 2009-03-03.00:00:00 last changed 183 months ago

Messages

Date: 2013-10-14.00:00:00

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.)

History
Date User Action Args
2009-03-03 00:00:00admincreate