[Boost-bugs] [Boost C++ Libraries] #10224: [property map] compilation error : make_function_property_map

Subject: [Boost-bugs] [Boost C++ Libraries] #10224: [property map] compilation error : make_function_property_map
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-07-22 11:02:02


#10224: [property map] compilation error : make_function_property_map
-----------------------------------------------+--------------------------
 Reporter: Akira Takahashi <faithandbrave@…> | Owner: dgregor
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: property_map
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
-----------------------------------------------+--------------------------
 `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);
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10224>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC