Skip to content
Snippets Groups Projects
Commit bf9de2e6 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Improve compatibility with gcc-4.2.1

parent 469d9088
Branches
Tags
1 merge request!5Improve compatibility with gcc-4.2.1
Pipeline #
#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
......
  • Maintainer

    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.

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment