Opened 14 years ago
Last modified 10 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)
Change History (6)
by , 14 years ago
Attachment: | template_keyword.1.patch added |
---|
by , 12 years ago
Attachment: | function_type_named_parameter.cpp added |
---|
compile test for passing function type as named template parameter
follow-up: 2 comment:1 by , 12 years ago
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 by , 12 years ago
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.
comment:3 by , 10 years ago
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.
Patch from David Abrahams for boost/parameter/aux_/template_keyword.hpp