[Multiindex] Const_mem_fun from base class
Hello, I get an error when I'm trying to use a const member function in a multi-index container, as a template parameter for indexed_by<>. This const member function comes from a base class, from which the class contained in the multiindex container is derived. The error is the following: /home/yardbird/documenti/work/prog/piranha/pyranha/Gsp/../../src/polynomial.h:41: error: could not convert template argument ‘&piranha::base_monomial_gmp_arraypiranha::double_cf::get_degree’ to ‘int (piranha::monomial_gmp_arraypiranha::double_cf::*)()const’ The member function is named "get_degree", and returns an integer. The base class is "base_monomial_gmp_array", the derived class is, unsurprisingly, "monomial_gmp_array". If I "lift" this function to the derived class, by re-defining it there, the problem disappears. I have a hunch that probably with some clever typedef or some static_cast wizardy this could be resolved, however my experiments have not resolved anything yet. Does anyone have an idea on how to proceed? Thanks in advance, Francesco Biscani.
Hi Francesco,
----- Mensaje original -----
De: Francesco Biscani
Hello,
I get an error when I'm trying to use a const member function in a multi-index container, as a template parameter for indexed_by<>. This const member function comes from a base class, from which the class contained in the multiindex container is derived. The error is the following:
/home/yardbird/documenti/work/prog/piranha/pyranha/Gsp/../../src/ polynomial.h:41: error: could not convert template argument ‘&piranha::base_monomial_gmp_arraypiranha::double_cf::get_degree’ to ‘int (piranha::monomial_gmp_arraypiranha::double_cf::*)()const’ [...]
This is probably #1 B.MI-related FAQ as of the last few months :)
Please read the following post where the issue is explained:
http://lists.boost.org/boost-users/2006/12/24042.php
To sum it up, you've got two options:
1. If you're already using Boost 1.34, use the following key
extractor:
const_mem_fun<
base_monomial_gmp_array
2. If you have to stick to Boost 1.33.1, write up a custom key extractor. Does this help? Thanks for using Boost.MultiIndex, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (2)
-
"JOAQUIN LOPEZ MU?Z"
-
Francesco Biscani