Opened 8 years ago
#10224 new Bugs
[property map] compilation error : make_function_property_map
Reported by: | Owned by: | Douglas Gregor | |
---|---|---|---|
Milestone: | To Be Determined | Component: | property_map |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
make_function_property_map()
function can not apply function pointer.
#include <boost/property_map/function_property_map.hpp> int get_prop(double) { return 1; } struct get_prop_functor { typedef int result_type; result_type operator()(double) const { return 1; } }; int main() { const auto p1 = boost::make_function_property_map<double>(get_prop); // compilation error const auto p2 = boost::make_function_property_map<double>(get_prop_functor()); // OK }
error message (with gcc 4.8)
/Users/hogehoge/language/cpp/main.cpp: In function 'int main()': /Users/hogehoge/language/cpp/main.cpp:14:71: error: no matching function for call to 'make_function_property_map(int (&)(double))' const auto p1 = boost::make_function_property_map<double>(get_prop); // compilation error ^ /Users/hogehoge/language/cpp/main.cpp:14:71: note: candidates are: In file included from /Users/hogehoge/language/cpp/main.cpp:1:0: /Users/hogehoge/repository/GitHub/boost-develop/boost/property_map/function_property_map.hpp:54:1: note: template<class Key, class Func> boost::function_property_map<Func, Key> boost::make_function_property_map(const Func&) make_function_property_map(const Func& f) { ^ /Users/hogehoge/repository/GitHub/boost-develop/boost/property_map/function_property_map.hpp:54:1: note: template argument deduction/substitution failed: /Users/hogehoge/repository/GitHub/boost-develop/boost/property_map/function_property_map.hpp: In substitution of 'template<class Key, class Func> boost::function_property_map<Func, Key> boost::make_function_property_map(const Func&) [with Key = double; Func = int(double)]': /Users/hogehoge/language/cpp/main.cpp:14:71: required from here /Users/hogehoge/repository/GitHub/boost-develop/boost/property_map/function_property_map.hpp:54:1: error: function returning a function /Users/hogehoge/repository/GitHub/boost-develop/boost/property_map/function_property_map.hpp:60:1: note: template<class Key, class Ret, class Func> boost::function_property_map<Func, Key, Ret> boost::make_function_property_map(const Func&) make_function_property_map(const Func& f) { ^ /Users/hogehoge/repository/GitHub/boost-develop/boost/property_map/function_property_map.hpp:60:1: note: template argument deduction/substitution failed: /Users/hogehoge/language/cpp/main.cpp:14:71: note: couldn't deduce template parameter 'Ret' const auto p1 = boost::make_function_property_map<double>(get_prop); // compilation error
I think should remove const &
from parameter.
before:
template<typename Key, typename Func> function_property_map<Func, Key> make_function_property_map(const Func& f) { return function_property_map<Func, Key>(f); } template<typename Key, typename Ret, typename Func> function_property_map<Func, Key, Ret> make_function_property_map(const Func& f) { return function_property_map<Func, Key, Ret>(f); }
after:
template<typename Key, typename Func> function_property_map<Func, Key> make_function_property_map(Func f) { return function_property_map<Func, Key>(f); } template<typename Key, typename Ret, typename Func> function_property_map<Func, Key, Ret> make_function_property_map(Func f) { return function_property_map<Func, Key, Ret>(f); }
Note:
See TracTickets
for help on using tickets.