Commit bf9de2e6 authored by André Anjos's avatar André Anjos 💬

Improve compatibility with gcc-4.2.1

parent 469d9088
Pipeline #7073 canceled with stages
in 59 seconds
#include "main.h" #include "main.h"
#include <boost/type_index.hpp>
#include <boost/functional/hash.hpp>
static auto lutMachine_doc = bob::extension::ClassDoc( static auto lutMachine_doc = bob::extension::ClassDoc(
"LUTMachine", "LUTMachine",
...@@ -408,7 +410,7 @@ bool init_LUTMachine(PyObject* module) ...@@ -408,7 +410,7 @@ bool init_LUTMachine(PyObject* module)
LUTMachineType.tp_methods = lutMachine_Methods; LUTMachineType.tp_methods = lutMachine_Methods;
// register machine // 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; return false;
// check that everyting is fine // check that everyting is fine
......
#include "main.h" #include "main.h"
#include <boost/type_index.hpp>
#include <boost/functional/hash.hpp>
static auto stumpMachine_doc = bob::extension::ClassDoc( static auto stumpMachine_doc = bob::extension::ClassDoc(
"StumpMachine", "StumpMachine",
...@@ -410,7 +412,7 @@ bool init_StumpMachine(PyObject* module) ...@@ -410,7 +412,7 @@ bool init_StumpMachine(PyObject* module)
StumpMachineType.tp_methods = stumpMachine_Methods; StumpMachineType.tp_methods = stumpMachine_Methods;
// register machine // 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; return false;
// check that everyting is fine // check that everyting is fine
......
#include "main.h" #include "main.h"
#include <boost/type_index.hpp>
#include <boost/functional/hash.hpp>
static std::map<size_t,CreateFunction> machineFactory; static std::map<size_t,CreateFunction> machineFactory;
...@@ -13,7 +15,7 @@ bool registerMachineType(size_t type_hash, CreateFunction creator_function){ ...@@ -13,7 +15,7 @@ bool registerMachineType(size_t type_hash, CreateFunction creator_function){
} }
PyObject* createMachine(boost::shared_ptr<bob::learn::boosting::WeakMachine> machine){ 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()){ if (machineFactory.find(type_hash) == machineFactory.end()){
PyErr_Format(PyExc_TypeError, "The given machine hash %zu has not been registered.", type_hash); PyErr_Format(PyExc_TypeError, "The given machine hash %zu has not been registered.", type_hash);
return NULL; return NULL;
...@@ -60,7 +62,7 @@ bool init_WeakMachine(PyObject* module){ ...@@ -60,7 +62,7 @@ bool init_WeakMachine(PyObject* module){
// register creator function // register creator function
// register machine // 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; return false;
// check that everyting is fine // check that everyting is fine
......
  • Although this commit is more than a year old, I have just figured out that I have an issue with it. This requires functionality introduced in Boost version 1.60.0. The default Ubuntu 14.04 distribution only comes with Boost version 1.54.0.

    This requirement is not mentioned anywhere. I know that people should use the conda installation, but this commit disallows to use pip on Ubuntu 14.04.

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