Boost C++ Libraries: Ticket #10224: [property map] compilation error : make_function_property_map
https://svn.boost.org/trac10/ticket/10224
<p>
<code>make_function_property_map()</code> function can not apply function pointer.
</p>
<pre class="wiki">#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
}
</pre><p>
error message (with gcc 4.8)
</p>
<pre class="wiki">/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
</pre><p>
I think should remove <code>const &</code> from parameter.
</p>
<p>
before:
</p>
<pre class="wiki">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);
}
</pre><p>
after:
</p>
<pre class="wiki">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);
}
</pre>
en-us
Boost C++ Libraries
/htdocs/site/boost.png
https://svn.boost.org/trac10/ticket/10224
Trac 1.4.3