diff --git a/include/GenericToolbox.Json.h b/include/GenericToolbox.Json.h index aa9e44e..f2b6ddf 100644 --- a/include/GenericToolbox.Json.h +++ b/include/GenericToolbox.Json.h @@ -129,14 +129,14 @@ namespace GenericToolbox { inline JsonType getForwardedConfig(const JsonType& config_) { JsonType out = config_; while( out.is_string() ){ - out = readConfigFile(out.template get()); + out = readConfigFile(out.get()); } return out; } inline void forwardConfig(JsonType& config_, const std::string& className_){ while( config_.is_string() ){ - std::cout << "Forwarding " << (className_.empty()? "": className_ + " ") << "config: \"" << config_.template get() << "\"" << std::endl; - auto name = config_.template get(); + std::cout << "Forwarding " << (className_.empty()? "": className_ + " ") << "config: \"" << config_.get() << "\"" << std::endl; + auto name = config_.get(); std::string expand = expandEnvironmentVariables(name); config_ = readConfigFile(expand); } @@ -144,7 +144,7 @@ namespace GenericToolbox { inline void unfoldConfig(JsonType& config_){ for( auto& entry : config_ ){ if( entry.is_string() and ( - endsWith(entry.template get(), ".json", true) + endsWith(entry.get(), ".json", true) ) ){ forwardConfig(entry); unfoldConfig(config_); // remake the loop on the unfolder config @@ -245,7 +245,7 @@ namespace GenericToolbox { for( auto& condEntry : jsonList ){ if( condEntry.is_string() ){ - conditionsList.emplace_back( condEntry.template get() ); + conditionsList.emplace_back( condEntry.get() ); } else{ std::cout << "Could not recognise condition entry: " << condEntry << std::endl; @@ -334,7 +334,7 @@ namespace GenericToolbox { } template JsonType fetchMatchingEntry(const JsonType& jsonConfig_, const std::string& keyPath_, const T& keyValue_){ if( jsonConfig_.empty() or not jsonConfig_.is_array() ){ return {}; } - for(const auto& jsonEntry : jsonConfig_.template get>() ){ + for(const auto& jsonEntry : jsonConfig_.get>() ){ try{ if( fetchValue(jsonEntry, keyPath_) == keyValue_ ){ return jsonEntry; } } catch (...){} // next } @@ -575,17 +575,17 @@ namespace GenericToolbox { namespace Internal{ template T getImpl(const JsonType& json_, T*){ - return json_.template get(); + return json_.get(); } inline double getImpl(const JsonType& json_, double*){ // better handling of nan if( json_.is_string() ){ - if( json_.template get() == "nan" ){ return std::nan("nan"); } - if( json_.template get() == "null" ){ return std::nan("null"); } + if( json_.get() == "nan" ){ return std::nan("nan"); } + if( json_.get() == "null" ){ return std::nan("null"); } // otherwise it is a string that should be castable as a double } if( json_.is_null() ){ return std::nan("null"); } // macOS - return json_.template get(); + return json_.get(); } inline Range getImpl(const JsonType& json_, Range*){ if( not json_.is_array() ){ throw std::runtime_error("provided json is not an array."); } diff --git a/include/GenericToolbox.Switch.h b/include/GenericToolbox.Switch.h index fb444fc..5a723c3 100644 --- a/include/GenericToolbox.Switch.h +++ b/include/GenericToolbox.Switch.h @@ -348,9 +348,9 @@ namespace GenericToolbox::Switch { const std::string &title_, bool forcePrint_, const std::string& color_ ){ - if(forcePrint_ or ProgressBar::gProgressBar.template showProgressBar(iCurrent_, iTotal_) ){ + if(forcePrint_ or ProgressBar::gProgressBar.showProgressBar(iCurrent_, iTotal_) ){ ProgressBar::gProgressBar.setDisableVt100Cmd( true ); - printRight(ProgressBar::gProgressBar.template generateProgressBarStr(iCurrent_, iTotal_, GenericToolbox::padString(title_, 40)), color_, true); + printRight(ProgressBar::gProgressBar.generateProgressBarStr(iCurrent_, iTotal_, GenericToolbox::padString(title_, 40)), color_, true); consoleUpdate(nullptr); } } diff --git a/include/GenericToolbox.Utils.h b/include/GenericToolbox.Utils.h index 6760bf8..26813e3 100644 --- a/include/GenericToolbox.Utils.h +++ b/include/GenericToolbox.Utils.h @@ -368,16 +368,16 @@ namespace GenericToolbox{ } template static std::string generateProgressBarStr( const T& iCurrent_, const TT& iTotal_, const std::string &title_ ){ - return ProgressBar::gProgressBar.template generateProgressBarStr(iCurrent_, iTotal_, title_); + return ProgressBar::gProgressBar.generateProgressBarStr(iCurrent_, iTotal_, title_); } template static bool showProgressBar(const T& iCurrent_, const TT& iTotal_){ - return ProgressBar::gProgressBar.template showProgressBar(iCurrent_, iTotal_); + return ProgressBar::gProgressBar.showProgressBar(iCurrent_, iTotal_); } template static std::string getProgressBarStr(const T& iCurrent_, const TT& iTotal_, const std::string &title_, bool forcePrint_ ){ - return ProgressBar::gProgressBar.template getProgressBarStr(iCurrent_, iTotal_, title_, forcePrint_); + return ProgressBar::gProgressBar.getProgressBarStr(iCurrent_, iTotal_, title_, forcePrint_); } template static void displayProgressBar(const T& iCurrent_, const TT& iTotal_, const std::string &title_, bool forcePrint_) { - return ProgressBar::gProgressBar.template displayProgressBar(iCurrent_, iTotal_, title_, forcePrint_); + return ProgressBar::gProgressBar.displayProgressBar(iCurrent_, iTotal_, title_, forcePrint_); } static void resetLastDisplayedValue(){ ProgressBar::gProgressBar.resetLastDisplayedValue(); @@ -439,7 +439,10 @@ namespace GenericToolbox{ } Range& operator+=(double shift_){ min += shift_; max += shift_; return *this; } - Range& operator-=(double shift_){ min -= shift_; max -= shift_; return *this; } + Range& operator-=(double shift_){ *this += -shift_; return *this; } + bool operator==(const Range& other_) const { return min == other_.min && max == other_.max; } + bool operator!=(const Range& other_) const { return !(*this == other_); } + friend std::ostream& operator <<( std::ostream& o, const Range& this_ ){ o << this_.toString(); return o; } }; } @@ -1202,7 +1205,7 @@ namespace GenericToolbox{ // Structs to decide if a stream function can be impl if( other_._varPtr_ != nullptr ){ this->_varPtr_ = std::unique_ptr(other_._varPtr_->clone()); } } template inline AnyType::AnyType(const ValueType& value_){ - this->template setValue(value_); + this->setValue(value_); } template inline AnyType& AnyType::operator=(const ValueType & rhs) { diff --git a/include/GenericToolbox.Vector.h b/include/GenericToolbox.Vector.h index c197589..897b425 100644 --- a/include/GenericToolbox.Vector.h +++ b/include/GenericToolbox.Vector.h @@ -130,7 +130,7 @@ namespace GenericToolbox { } template static void addIfNotInVector(const T& element_, std::vector &vector_){ if( not GenericToolbox::doesElementIsInVector(element_, vector_) ){ - vector_.template emplace_back(element_); + vector_.emplace_back(element_); } } static void addIfNotInVector(const char* element_, std::vector &vector_){ diff --git a/include/GenericToolbox.Yaml.h b/include/GenericToolbox.Yaml.h index e9f25c8..c514df0 100644 --- a/include/GenericToolbox.Yaml.h +++ b/include/GenericToolbox.Yaml.h @@ -67,7 +67,7 @@ namespace GenericToolbox { throw std::runtime_error(keyName_ + " does not exist"); } - return yamlConfig_[keyName_].template as(); + return yamlConfig_[keyName_].as(); } template inline auto fetchValue(const YAML::Node& yamlConfig_, const std::string& keyName_, const T& defaultValue_) -> T{ try{ @@ -85,7 +85,7 @@ namespace GenericToolbox { } for( const auto& yamlEntry : yamlConfig_ ){ - if(yamlEntry[keyName_] and yamlEntry[keyName_].template as() == keyValue_ ){ + if(yamlEntry[keyName_] and yamlEntry[keyName_].as() == keyValue_ ){ return YAML::Node(yamlEntry); } }