Modify

Opened 9 years ago

Last modified 5 years ago

#2793 new Bugs

function types don't work for named template type parameters

Reported by: Frank Mori Hess Owned by: Daniel Wallin
Milestone: Boost 1.39.0 Component: parameter
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:

Description

See this thread for a more detailed description:

http://www.nabble.com/-parameter--function-types-as-named-template-parameters--td21614543.html

Dave Abrahams posted a patch for this problem to the mailing list, I will attach it to this ticket.

Attachments (3)

template_keyword.1.patch (1.4 KB) - added by Frank Mori Hess 9 years ago.
Patch from David Abrahams for boost/parameter/aux_/template_keyword.hpp
function_type_named_parameter.cpp (1011 bytes) - added by Frank Mori Hess 8 years ago.
compile test for passing function type as named template parameter
arg_list.diff (4.4 KB) - added by Louis Dionne <louis.dionne92@…> 5 years ago.
temporary workaround

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by Frank Mori Hess

Attachment: template_keyword.1.patch added

Patch from David Abrahams for boost/parameter/aux_/template_keyword.hpp

Changed 8 years ago by Frank Mori Hess

compile test for passing function type as named template parameter

comment:1 Changed 8 years ago by Frank Mori Hess

The function_type_named_parameter.cpp test actually fails even with the patch, due to the function type being changed into a reference to function type. I believe the test is valid and the patch is not quite right. I couldn't say exactly what practical difference it would make that the function type is changed into a reference to function type, but it seems wrong that the type is not exactly preserved.

comment:2 in reply to:  1 Changed 7 years ago by expaler

Replying to fmhess:

I believe the test is valid and the patch is not quite right.

I hope you don't mind if I disagree with your assessment. The reference documentation does state that the binding metafunction returns the reference type rather than the value type. Of course, if the patch is applied, then perhaps the documentation should be changed to reflect the fact that the metafunction returns the reference type only if the tagged reference is a primitive function or array. Or perhaps not, since metaprogrammers can just add_reference.

In any case, I don't see why legacy code that is already broken for function types shouldn't be changed to use value_type instead of binding. I vote to have the patch applied.

Changed 5 years ago by Louis Dionne <louis.dionne92@…>

Attachment: arg_list.diff added

temporary workaround

comment:3 Changed 5 years ago by Louis Dionne <louis.dionne92@…>

I have run into this problem too.

Instead of changing the definition of reference, I opted for a more conservative solution. Since I was getting compiler errors in the declarations of some member functions of arg_list, I changed these declarations so that the problematic types are dependent on a template parameter. Since the functions are never actually used for named template parameters, the signatures are not instantiated and the compiler does not complain.

Attached is a patch that makes the function_type_named_parameter.cpp test pass. My own code also works with this patch. While this is a hacky workaround, I believe it is still better than nothing until a definite solution can be settled on.

I compiled with Clang 3.2 and G++ 4.7.2.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Daniel Wallin.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.