Commit 1daf64db authored by André Anjos's avatar André Anjos

Merge branch 'gcc421' into 'master'

Improve compatibility with gcc-4.2.1

See merge request !5
parents 469d9088 bf9de2e6
Pipeline #7074 passed with stages
in 17 minutes and 43 seconds
#include "main.h"
#include <boost/type_index.hpp>
#include <boost/functional/hash.hpp>
static auto lutMachine_doc = bob::extension::ClassDoc(
"LUTMachine",
......@@ -408,7 +410,7 @@ bool init_LUTMachine(PyObject* module)
LUTMachineType.tp_methods = lutMachine_Methods;
// register machine
if (!registerMachineType(typeid(bob::learn::boosting::LUTMachine).hash_code(), &lutMachineCreate))
if (!registerMachineType(boost::typeindex::type_id<bob::learn::boosting::LUTMachine>().hash_code(), &lutMachineCreate))
return false;
// check that everyting is fine
......
#include "main.h"
#include <boost/type_index.hpp>
#include <boost/functional/hash.hpp>
static auto stumpMachine_doc = bob::extension::ClassDoc(
"StumpMachine",
......@@ -410,7 +412,7 @@ bool init_StumpMachine(PyObject* module)
StumpMachineType.tp_methods = stumpMachine_Methods;
// register machine
if (!registerMachineType(typeid(bob::learn::boosting::StumpMachine).hash_code(), &stumpMachineCreate))
if (!registerMachineType(boost::typeindex::type_id<bob::learn::boosting::StumpMachine>().hash_code(), &stumpMachineCreate))
return false;
// check that everyting is fine
......
#include "main.h"
#include <boost/type_index.hpp>
#include <boost/functional/hash.hpp>
static std::map<size_t,CreateFunction> machineFactory;
......@@ -13,7 +15,7 @@ bool registerMachineType(size_t type_hash, CreateFunction creator_function){
}
PyObject* createMachine(boost::shared_ptr<bob::learn::boosting::WeakMachine> machine){
size_t type_hash = typeid(*machine).hash_code();
size_t type_hash = boost::typeindex::type_id_runtime(*machine).hash_code();
if (machineFactory.find(type_hash) == machineFactory.end()){
PyErr_Format(PyExc_TypeError, "The given machine hash %zu has not been registered.", type_hash);
return NULL;
......@@ -60,7 +62,7 @@ bool init_WeakMachine(PyObject* module){
// register creator function
// register machine
if (!registerMachineType(typeid(bob::learn::boosting::WeakMachine).hash_code(), &weakMachineCreate))
if (!registerMachineType(boost::typeindex::type_id<bob::learn::boosting::WeakMachine>().hash_code(), &weakMachineCreate))
return false;
// check that everyting is fine
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment