Commit 63151011 authored by Christophe Gonzales's avatar Christophe Gonzales

fix compilation issues in Visual Studio 15

parent caa7dbc0
Pipeline #20452901 passed with stages
in 72 minutes and 42 seconds
......@@ -585,6 +585,21 @@ namespace gum {
template <>
class HashFunc< unsigned long > : public HashFuncSmallKey< unsigned long > {};
template <typename T>
class dummyHash {};
/**
* @headerfile hashFunc.h <agrum/core/hashFunc.h>
* @brief Hash function for std::size_t.
* @ingroup hashfunctions_group
*/
template <>
class HashFunc< std::conditional<
std::is_same<std::size_t,unsigned long>::value,
dummyHash<std::size_t>,
std::size_t >::type > :
public HashFuncCastKey< std::size_t >::type {};
/**
* @headerfile hashFunc.h <agrum/core/hashFunc.h>
* @brief Hash function for floats.
......
......@@ -32,7 +32,8 @@ namespace gum {
initializer.fillDatabase ( __database );
// get the domain sizes of the variables
__modalities = __database.domainSizes ();
for ( auto dom : __database.domainSizes () )
__modalities.push_back ( dom );
nb_vars = __database.nbVariables ();
for ( std::size_t i = std::size_t(0); i < nb_vars; ++i )
......
......@@ -86,14 +86,14 @@ namespace gum {
last_letter_token = __correspondingQuoteMarker( str, first_letter_token );
if ( last_letter_token == std::string::npos )
GUM_SYNTAX_ERROR( "String quote missing", nbLine(), first_letter_token );
GUM_SYNTAX_ERROR( "String quote missing", (Size) nbLine(), first_letter_token );
next_token = str.find_first_of( __delimiter, last_letter_token + 1 );
std::size_t next_char =
str.find_first_not_of( __spaces, last_letter_token + 1 );
if ( next_char < next_token ) {
GUM_SYNTAX_ERROR( "Delimiter missing at line", nbLine(), next_char );
GUM_SYNTAX_ERROR( "Delimiter missing at line", (Size) nbLine(), next_char );
}
}
else {
......@@ -124,7 +124,7 @@ namespace gum {
quoteMarkerEnd = __correspondingQuoteMarker( s, quoteMarker );
if ( quoteMarkerEnd == std::string::npos )
GUM_SYNTAX_ERROR( "String quote missing", nbLine(), quoteMarker );
GUM_SYNTAX_ERROR( "String quote missing", (Size) nbLine(), quoteMarker );
while ( commentMarker < quoteMarkerEnd ) { // the comment was in the quote
commentMarker = s.find_first_of( __commentMarker, commentMarker + 1 );
......
......@@ -143,7 +143,7 @@ namespace gum {
// produce the new generators
ALLOC<DBRowGenerator<ALLOC>> allocator ( this->getAllocator () );
std::vector<DBRowGenerator<ALLOC>*,ALLOC<DBRowGenerator<ALLOC>*>>
new_generators ( from.__nb_generators, allocator );
new_generators ( from.__nb_generators, nullptr, allocator );
for (std::size_t i = std::size_t(0); i < from.__nb_generators; ++i) {
try {
new_generators[i] = from.__generators[i]->clone ( allocator );
......
......@@ -58,12 +58,12 @@ namespace gum {
// copy the ticks of var into our internal variable
const auto& ticks = var.ticks ();
for ( const auto tick : ticks ) {
__variable.addTick ( tick );
__variable.addTick ( (float) tick );
}
// the the bounds of the discretized variable
const float lower_bound = ticks[0];
const float upper_bound = ticks.back ();
const float lower_bound = (float) ticks[0];
const float upper_bound = (float) ticks.back ();
// remove all the missing symbols corresponding to a number between
// lower_bound and upper_bound
......@@ -118,7 +118,7 @@ namespace gum {
// copy the ticks of var into our internal variable
const auto& ticks = var.ticks ();
for ( const auto tick : ticks ) {
__variable.addTick ( tick );
__variable.addTick ( (float) tick );
}
// add the content of the variable into the back dictionary
......@@ -322,7 +322,8 @@ namespace gum {
DBTranslator4DiscretizedVariable<ALLOC>::reorder () {
const std::size_t size = __variable.domainSize ();
HashTable<std::size_t,std::size_t,
ALLOC<std::pair<std::size_t,std::size_t>>> mapping ( size );
ALLOC<std::pair<std::size_t,std::size_t>>>
mapping ( (Size) size );
for ( std::size_t i = std::size_t (0); i < size; ++i )
mapping.insert ( i,i );
return mapping;
......
......@@ -338,7 +338,8 @@ namespace gum {
// indices to the new one
this->_back_dico.clear ();
HashTable<std::size_t,std::size_t,
ALLOC<std::pair<std::size_t,std::size_t>>> mapping ( size );
ALLOC<std::pair<std::size_t,std::size_t>>>
mapping ( (Size) size );
for ( std::size_t i = std::size_t(0); i < size; ++i ) {
mapping.insert ( xlabels[i].first, i );
this->_back_dico.insert ( i, xlabels[i].second );
......
......@@ -487,8 +487,8 @@ namespace gum {
bool DBTranslator4RangeVariable<ALLOC>::needsReordering () {
// if the variable contains only numbers, they should be increasing
const auto& labels = __variable.labels ();
float last_number = std::numeric_limits<float>::lowest ();
float number;
std::size_t last_number = std::numeric_limits<std::size_t>::lowest ();
std::size_t number;
for ( const auto& label : labels ) {
number = this->_back_dico.first ( label );
if ( number < last_number ) return true;
......@@ -518,7 +518,8 @@ namespace gum {
// indices to the new one
this->_back_dico.clear ();
HashTable<std::size_t,std::size_t,
ALLOC<std::pair<std::size_t,std::size_t>>> mapping ( size );
ALLOC<std::pair<std::size_t,std::size_t>>>
mapping ( (Size) size );
for ( std::size_t i = std::size_t(0); i < size; ++i ) {
mapping.insert ( xlabels[i].first, i );
this->_back_dico.insert ( i, xlabels[i].second );
......
......@@ -64,7 +64,7 @@ namespace gum {
if ( size ) {
// save the set of symbols representing the missing values
_missing_symbols.resize ( missing_symbols.size () );
_missing_symbols.resize ( (Size) missing_symbols.size () );
for ( const auto& symbol : missing_symbols ) {
_missing_symbols.insert ( symbol );
}
......
......@@ -582,31 +582,6 @@ namespace gum {
: IDatabaseTable<T_DATA,ALLOC> ( std::move (from), from.getAllocator () ) {}
/// virtual copy constructor with a given allocator
template <typename T_DATA, template<typename> class ALLOC>
IDatabaseTable<T_DATA,ALLOC>*
IDatabaseTable<T_DATA,ALLOC>::clone ( const allocator_type& alloc ) const {
ALLOC<IDatabaseTable<T_DATA,ALLOC>> allocator ( alloc );
IDatabaseTable<T_DATA,ALLOC>* set = allocator.allocate(1);
try {
allocator.construct ( set, *this, alloc );
}
catch ( ... ) {
allocator.deallocate ( set, 1 );
throw;
}
return set;
}
/// virtual copy constructor
template <typename T_DATA, template<typename> class ALLOC>
INLINE IDatabaseTable<T_DATA,ALLOC>*
IDatabaseTable<T_DATA,ALLOC>::clone () const {
return clone ( this->getAllocator () );
}
// destructor
template <typename T_DATA, template<typename> class ALLOC>
IDatabaseTable<T_DATA,ALLOC>::~IDatabaseTable() {
......
......@@ -35,6 +35,7 @@
#include <agrum/core/set.h>
#include <agrum/learning/database/DBCell.h>
#include <agrum/learning/database/DBRow.h>
#include <agrum/learning/database/DBTranslatedValue.h>
#include <agrum/learning/database/IDatabaseTable.h>
#include <agrum/learning/database/DBTranslatorSet.h>
#include <agrum/learning/database/DBTranslator4ContinuousVariable.h>
......
......@@ -146,7 +146,7 @@ namespace gum_tests {
var.addLabel ( "L1" );
var.addLabel ( "L2" );
gum::learning::DBTranslator4LabelizedVariable<>
translator ( var, missing, 3 );
translator ( var, missing, true, 3 );
set.insertTranslator ( translator, 0 );
set.insertTranslator ( translator, 1 );
set.insertTranslator ( translator, 2 );
......@@ -290,7 +290,7 @@ namespace gum_tests {
var.addLabel ( "L1" );
var.addLabel ( "L2" );
gum::learning::DBTranslator4LabelizedVariable<>
translator ( var, missing, 3 );
translator ( var, missing, true, 3 );
set.insertTranslator ( translator, 0 );
set.insertTranslator ( translator, 1 );
set.insertTranslator ( translator, 2 );
......@@ -373,7 +373,7 @@ namespace gum_tests {
std::vector<std::string> missing { "?", "N/A", "???" };
gum::ContinuousVariable<float> var ( "var", "" );
gum::learning::DBTranslator4ContinuousVariable<>
translator ( var, missing, 3 );
translator ( var, missing, true );
set.insertTranslator ( translator, 0 );
set.insertTranslator ( translator, 1 );
set.insertTranslator ( translator, 2 );
......@@ -456,7 +456,7 @@ namespace gum_tests {
std::vector<std::string> missing { "?", "N/A", "???" };
gum::ContinuousVariable<float> var ( "var", "" );
gum::learning::DBTranslator4ContinuousVariable<>
translator ( var, missing, 3 );
translator ( var, missing, true );
set.insertTranslator ( translator, 0 );
set.insertTranslator ( translator, 1 );
set.insertTranslator ( translator, 2 );
......@@ -507,7 +507,7 @@ namespace gum_tests {
std::vector<std::string> missing { "?", "N/A", "???" };
gum::ContinuousVariable<float> var ( "var", "" );
gum::learning::DBTranslator4ContinuousVariable<>
translator ( var, missing, 3 );
translator ( var, missing, true );
gum::learning::DatabaseTable<> database;
translator.setVariableName ( "v1" );
......@@ -571,7 +571,7 @@ namespace gum_tests {
std::vector<std::string> missing { "?", "N/A", "???" };
gum::ContinuousVariable<float> var ( "var", "" );
gum::learning::DBTranslator4ContinuousVariable<>
translator ( var, missing, 3 );
translator ( var, missing, true );
set.insertTranslator ( translator, 0 );
set.insertTranslator ( translator, 1 );
set.insertTranslator ( translator, 2 );
......@@ -637,7 +637,7 @@ namespace gum_tests {
std::vector<std::string> missing { "?", "N/A", "???" };
gum::ContinuousVariable<float> var ( "var", "" );
gum::learning::DBTranslator4ContinuousVariable<>
translator ( var, missing, 3 );
translator ( var, missing, true );
set.insertTranslator ( translator, 0 );
set.insertTranslator ( translator, 1 );
set.insertTranslator ( translator, 2 );
......@@ -703,7 +703,7 @@ namespace gum_tests {
std::vector<std::string> missing { "?", "N/A", "???" };
gum::ContinuousVariable<float> var ( "var", "" );
gum::learning::DBTranslator4ContinuousVariable<>
translator ( var, missing, 3 );
translator ( var, missing, true );
set.insertTranslator ( translator, 0 );
set.insertTranslator ( translator, 1 );
set.insertTranslator ( translator, 2 );
......@@ -729,8 +729,8 @@ namespace gum_tests {
int nb_col1 = 0, nb_col2 = 0;
for ( const auto row : database ) {
const auto& r = row.row();
nb_col1 += r[0].cont_val;
nb_col2 += r[1].cont_val;
nb_col1 += (int) r[0].cont_val;
nb_col2 += (int) r[1].cont_val;
}
TS_ASSERT( nb_col1 == 8 );
TS_ASSERT( nb_col2 == 8 );
......@@ -739,8 +739,8 @@ namespace gum_tests {
nb_col2 = 0;
for ( auto iter = database.begin(); iter != database.end(); ++iter ) {
const auto& r = iter->row();
nb_col1 += r[0].cont_val;
nb_col2 += r[1].cont_val;
nb_col1 += (int) r[0].cont_val;
nb_col2 += (int) r[1].cont_val;
}
TS_ASSERT( nb_col1 == 8 );
TS_ASSERT( nb_col2 == 8 );
......@@ -750,8 +750,8 @@ namespace gum_tests {
for ( auto iter = database.beginSafe();
iter != database.endSafe(); ++iter ) {
const auto& r = (*iter).row();
nb_col1 += r[0].cont_val;
nb_col2 += r[1].cont_val;
nb_col1 += (int) r[0].cont_val;
nb_col2 += (int) r[1].cont_val;
}
TS_ASSERT( nb_col1 == 8 );
TS_ASSERT( nb_col2 == 8 );
......@@ -761,8 +761,8 @@ namespace gum_tests {
for ( auto iter = database.beginSafe();
iter != database.endSafe(); ++iter ) {
const auto& r = iter->row();
nb_col1 += r[0].cont_val;
nb_col2 += r[1].cont_val;
nb_col1 += (int) r[0].cont_val;
nb_col2 += (int) r[1].cont_val;
}
TS_ASSERT( nb_col1 == 8 );
TS_ASSERT( nb_col2 == 8 );
......@@ -777,8 +777,8 @@ namespace gum_tests {
nb_col2 = 0;
for ( const auto row : database ) {
const auto& r = row.row();
nb_col1 += r[0].cont_val;
nb_col2 += r[1].cont_val;
nb_col1 += (int) r[0].cont_val;
nb_col2 += (int) r[1].cont_val;
}
TS_ASSERT( nb_col1 == 17 );
TS_ASSERT( nb_col2 == 17 );
......@@ -788,8 +788,8 @@ namespace gum_tests {
for ( auto iter = database.beginSafe();
iter != database.endSafe(); ++iter ) {
const auto& r = (*iter).row();
nb_col1 += r[0].cont_val;
nb_col2 += r[1].cont_val;
nb_col1 += (int) r[0].cont_val;
nb_col2 += (int) r[1].cont_val;
}
TS_ASSERT( nb_col1 == 17 );
TS_ASSERT( nb_col2 == 17 );
......@@ -803,7 +803,7 @@ namespace gum_tests {
std::vector<std::string> missing { "?", "N/A", "???" };
gum::ContinuousVariable<float> var ( "var", "" );
gum::learning::DBTranslator4ContinuousVariable<>
translator ( var, missing, 3 );
translator ( var, missing, true );
for ( std::size_t i = std::size_t(0); i < std::size_t(6); ++i )
set.insertTranslator ( translator, i );
gum::learning::DatabaseTable<> database ( set );
......
......@@ -105,7 +105,9 @@ namespace gum_tests {
gum::learning::DBRowGeneratorParser<>
parser ( database.handler (), genset );
std::vector< gum::Size > modalities = database.domainSizes ();
std::vector< gum::Size > modalities;
for ( auto dom : database.domainSizes () )
modalities.push_back ( dom );
gum::learning::AprioriSmoothing<> apriori;
gum::learning::ScoreK2<> score(parser, modalities, apriori);
......@@ -185,7 +187,9 @@ namespace gum_tests {
gum::learning::DBRowGeneratorParser<>
parser ( database.handler (), genset );
std::vector< gum::Size > modalities = database.domainSizes ();
std::vector< gum::Size > modalities;
for ( auto dom : database.domainSizes () )
modalities.push_back ( dom );
gum::learning::AprioriSmoothing<> apriori;
gum::learning::ScoreK2<> score(parser, modalities, apriori);
......
......@@ -6,20 +6,20 @@
namespace gum_tests {
struct MyAllocCount {
static unsigned int allocs;
static unsigned int deallocs;
static std::size_t allocs;
static std::size_t deallocs;
static unsigned int nbAllocations() noexcept { return allocs; }
static std::size_t nbAllocations() noexcept { return allocs; }
static unsigned int nbDeallocations() noexcept { return deallocs; }
static std::size_t nbDeallocations() noexcept { return deallocs; }
static bool hasMeroryLeak() noexcept {
return allocs != MyAllocCount::deallocs;
}
};
unsigned int MyAllocCount::allocs{0};
unsigned int MyAllocCount::deallocs{0};
std::size_t MyAllocCount::allocs{0};
std::size_t MyAllocCount::deallocs{0};
template <typename T>
class MyAlloc : public MyAllocCount {
......@@ -36,9 +36,9 @@ namespace gum_tests {
template <typename U>
MyAlloc( const MyAlloc<U>& ) noexcept {}
bool operator== ( const MyAlloc<T>& ) { return true; }
bool operator== ( const MyAlloc<T>& ) const { return true; }
bool operator!= ( const MyAlloc<T>& ) { return false; }
bool operator!= ( const MyAlloc<T>& ) const { return false; }
T* allocate( std::size_t num ) {
MyAllocCount::allocs += num;
......
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