From d92f02204180f6700ace6538238519eef3c56ea2 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 8 Oct 2014 14:47:51 +0200 Subject: [PATCH] remove implicit inline keyword from header files --- Util/BoostFileSystemFix.h | 10 +-- Util/ComputeAngle.h | 8 +-- Util/ContainerUtils.h | 6 +- Util/DataStoreOptions.h | 2 +- Util/MachineInfo.h | 4 +- Util/NumericUtil.h | 2 +- Util/StdHashExtensions.h | 8 +-- Util/StringUtil.h | 146 -------------------------------------- Util/TrigonometryTables.h | 2 +- 9 files changed, 21 insertions(+), 167 deletions(-) diff --git a/Util/BoostFileSystemFix.h b/Util/BoostFileSystemFix.h index 99b325fc6..52e6cedbb 100644 --- a/Util/BoostFileSystemFix.h +++ b/Util/BoostFileSystemFix.h @@ -51,7 +51,7 @@ namespace filesystem // exists. The validate() function must be defined in the same namespace // as the target type, (boost::filesystem::path in this case), otherwise // it is not called -// inline void validate( +// void validate( // boost::any & v, // const std::vector & values, // boost::filesystem::path *, @@ -71,7 +71,7 @@ namespace filesystem // adapted from: // http://stackoverflow.com/questions/1746136/how-do-i-normalize-a-pathname-using-boostfilesystem -inline boost::filesystem::path +boost::filesystem::path portable_canonical(const boost::filesystem::path &relative_path, const boost::filesystem::path ¤t_path = boost::filesystem::current_path()) { @@ -118,7 +118,7 @@ portable_canonical(const boost::filesystem::path &relative_path, #if BOOST_FILESYSTEM_VERSION < 3 -inline path temp_directory_path() +path temp_directory_path() { char *buffer; buffer = tmpnam(nullptr); @@ -126,7 +126,7 @@ inline path temp_directory_path() return path(buffer); } -inline path unique_path(const path &) { return temp_directory_path(); } +path unique_path(const path &) { return temp_directory_path(); } #endif } @@ -136,7 +136,7 @@ inline path unique_path(const path &) { return temp_directory_path(); } #define BOOST_FILESYSTEM_VERSION 3 #endif -inline void AssertPathExists(const boost::filesystem::path &path) +void AssertPathExists(const boost::filesystem::path &path) { if (!boost::filesystem::is_regular_file(path)) { diff --git a/Util/ComputeAngle.h b/Util/ComputeAngle.h index 02f678a07..9cca90516 100644 --- a/Util/ComputeAngle.h +++ b/Util/ComputeAngle.h @@ -37,7 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Get angle of line segment (A,C)->(C,B), atan2 magic, formerly cosine theorem*/ template -inline static double GetAngleBetweenThreeFixedPointCoordinates(const CoordinateT &A, +static double GetAngleBetweenThreeFixedPointCoordinates(const CoordinateT &A, const CoordinateT &C, const CoordinateT &B) { @@ -46,10 +46,10 @@ inline static double GetAngleBetweenThreeFixedPointCoordinates(const CoordinateT const double v2x = (B.lon - C.lon) / COORDINATE_PRECISION; const double v2y = lat2y(B.lat / COORDINATE_PRECISION) - lat2y(C.lat / COORDINATE_PRECISION); - double angle = (atan2_lookup(v2y, v2x) - atan2_lookup(v1y, v1x)) * 180 / M_PI; - while (angle < 0) + double angle = (atan2_lookup(v2y, v2x) - atan2_lookup(v1y, v1x)) * 180. / M_PI; + while (angle < 0.) { - angle += 360; + angle += 360.; } return angle; } diff --git a/Util/ContainerUtils.h b/Util/ContainerUtils.h index ae61a15b0..6639fafbd 100644 --- a/Util/ContainerUtils.h +++ b/Util/ContainerUtils.h @@ -31,20 +31,20 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -template inline void sort_unique_resize(std::vector &vector) +template void sort_unique_resize(std::vector &vector) { std::sort(vector.begin(), vector.end()); const auto number_of_unique_elements = std::unique(vector.begin(), vector.end()) - vector.begin(); vector.resize(number_of_unique_elements); } -// template inline void sort_unique_resize_shrink_vector(std::vector &vector) +// template void sort_unique_resize_shrink_vector(std::vector &vector) // { // sort_unique_resize(vector); // vector.shrink_to_fit(); // } -// template inline void remove_consecutive_duplicates_from_vector(std::vector &vector) +// template void remove_consecutive_duplicates_from_vector(std::vector &vector) // { // const auto number_of_unique_elements = std::unique(vector.begin(), vector.end()) - vector.begin(); // vector.resize(number_of_unique_elements); diff --git a/Util/DataStoreOptions.h b/Util/DataStoreOptions.h index 7a76bfb6a..0d6163a6a 100644 --- a/Util/DataStoreOptions.h +++ b/Util/DataStoreOptions.h @@ -43,7 +43,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include // generate boost::program_options object for the routing part -inline bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &paths, bool & springclean) +bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &paths, bool & springclean) { // declare a group of options that will be allowed only on command line boost::program_options::options_description generic_options("Options"); diff --git a/Util/MachineInfo.h b/Util/MachineInfo.h index c5cb0522b..a9a88a1ec 100644 --- a/Util/MachineInfo.h +++ b/Util/MachineInfo.h @@ -33,7 +33,7 @@ enum Endianness BigEndian = 2 }; // Function is optimized to a single 'mov eax,1' on GCC, clang and icc using -O3 -inline Endianness GetMachineEndianness() +Endianness GetMachineEndianness() { int i(1); char *p = (char *)&i; @@ -45,7 +45,7 @@ inline Endianness GetMachineEndianness() } // Reverses Network Byte Order into something usable, compiles down to a bswap-mov combination -inline unsigned SwapEndian(unsigned x) +unsigned SwapEndian(unsigned x) { if (GetMachineEndianness() == LittleEndian) { diff --git a/Util/NumericUtil.h b/Util/NumericUtil.h index 57cbe3e78..b209b7aa2 100644 --- a/Util/NumericUtil.h +++ b/Util/NumericUtil.h @@ -31,7 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -template inline bool EpsilonCompare(const FloatT d1, const FloatT d2) +template bool EpsilonCompare(const FloatT d1, const FloatT d2) { return (std::abs(d1 - d2) < std::numeric_limits::epsilon()); } diff --git a/Util/StdHashExtensions.h b/Util/StdHashExtensions.h index 50cd337ee..02b050c2e 100644 --- a/Util/StdHashExtensions.h +++ b/Util/StdHashExtensions.h @@ -33,26 +33,26 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // this is largely inspired by boost's hash combine as can be found in // "The C++ Standard Library" 2nd Edition. Nicolai M. Josuttis. 2012. template -inline void hash_combine(std::size_t &seed, const T& val) +void hash_combine(std::size_t &seed, const T& val) { seed ^= std::hash()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } template -inline void hash_val(std::size_t &seed, const T& val) +void hash_val(std::size_t &seed, const T& val) { hash_combine(seed, val); } template -inline void hash_val(std::size_t &seed, const T& val, const Types& ... args) +void hash_val(std::size_t &seed, const T& val, const Types& ... args) { hash_combine(seed, val); hash_val(seed, args ...); } template -inline std::size_t hash_val( const Types&... args) +std::size_t hash_val( const Types&... args) { std::size_t seed = 0; hash_val(seed, args...); diff --git a/Util/StringUtil.h b/Util/StringUtil.h index 4805f74db..49fa8bb76 100644 --- a/Util/StringUtil.h +++ b/Util/StringUtil.h @@ -29,13 +29,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define STRINGUTIL_H #include -#include -#include #include #include #include -#include #include // precision: position after decimal point @@ -74,149 +71,6 @@ template static inline char *printInt(char *buffer, return buffer; } -// convert scoped enums to integers -template -auto as_integer(Enumeration const value) -> typename std::underlying_type::type -{ - return static_cast::type>(value); -} - -template -static inline typename std::enable_if::value, std::string>::type -IntegralToString(const Number value) -{ - std::string output; - std::back_insert_iterator sink(output); - - if (8 == sizeof(Number)) - { - boost::spirit::karma::generate(sink, boost::spirit::karma::long_long, value); - } - else - { - if (std::is_signed::value) - { - boost::spirit::karma::generate(sink, boost::spirit::karma::int_, value); - } - else - { - boost::spirit::karma::generate(sink, boost::spirit::karma::uint_, value); - } - } - return output; -} - -static inline int StringToInt(const std::string &input) -{ - auto first_digit = input.begin(); - // Delete any trailing white-spaces - while (first_digit != input.end() && std::isspace(*first_digit)) - { - ++first_digit; - } - int value = 0; - boost::spirit::qi::parse(first_digit, input.end(), boost::spirit::int_, value); - return value; -} - -static inline unsigned StringToUint(const std::string &input) -{ - auto first_digit = input.begin(); - // Delete any trailing white-spaces - while (first_digit != input.end() && (std::isspace(*first_digit) || '-' == *first_digit)) - { - ++first_digit; - } - unsigned value = 0; - boost::spirit::qi::parse(first_digit, input.end(), boost::spirit::uint_, value); - return value; -} - -static inline uint64_t StringToInt64(const std::string &input) -{ - auto first_digit = input.begin(); - // Delete any trailing white-spaces - while (first_digit != input.end() && std::isspace(*first_digit)) - { - ++first_digit; - } - uint64_t value = 0; - boost::spirit::qi::parse(first_digit, input.end(), boost::spirit::long_long, value); - return value; -} - -// source: http://tinodidriksen.com/2011/05/28/cpp-convert-string-to-double-speed/ -static inline double StringToDouble(const char *p) -{ - double r = 0.0; - bool neg = false; - if (*p == '-') - { - neg = true; - ++p; - } - while (*p >= '0' && *p <= '9') - { - r = (r * 10.0) + (*p - '0'); - ++p; - } - if (*p == '.') - { - double f = 0.0; - int n = 0; - ++p; - while (*p >= '0' && *p <= '9') - { - f = (f * 10.0) + (*p - '0'); - ++p; - ++n; - } - r += f / std::pow(10.0, n); - } - if (neg) - { - r = -r; - } - return r; -} - -template struct scientific_policy : boost::spirit::karma::real_policies -{ - // we want the numbers always to be in fixed format - static int floatfield(T n) { return boost::spirit::karma::real_policies::fmtflags::fixed; } - static unsigned int precision(T) { return 6; } -}; -typedef boost::spirit::karma::real_generator> science_type; - -static inline std::string FixedDoubleToString(const double value) -{ - std::string output; - std::back_insert_iterator sink(output); - boost::spirit::karma::generate(sink, science_type(), value); - if (output.size() >= 2 && output[output.size() - 2] == '.' && output[output.size() - 1] == '0') - { - output.resize(output.size() - 2); - } - return output; -} - -static inline std::string DoubleToString(const double value) -{ - std::string output; - std::back_insert_iterator sink(output); - boost::spirit::karma::generate(sink, value); - return output; -} - -static inline void doubleToStringWithTwoDigitsBehindComma(const double value, std::string &output) -{ - // The largest 32-bit integer is 4294967295, that is 10 chars - // On the safe side, add 1 for sign, and 1 for trailing zero - char buffer[12]; - sprintf(buffer, "%g", value); - output = buffer; -} - inline void replaceAll(std::string &s, const std::string &sub, const std::string &other) { boost::replace_all(s, sub, other); diff --git a/Util/TrigonometryTables.h b/Util/TrigonometryTables.h index d14540482..64076a23c 100644 --- a/Util/TrigonometryTables.h +++ b/Util/TrigonometryTables.h @@ -722,7 +722,7 @@ constexpr unsigned short atan_table[4096] = { // max value is pi/4 constexpr double SCALING_FACTOR = 4. / M_PI * 0xFFFF; -inline double atan2_lookup(double y, double x) +double atan2_lookup(double y, double x) { if (std::abs(x) < std::numeric_limits::epsilon()) {