diff options
-rw-r--r-- | ripser.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -37,10 +37,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <sstream> #include <unordered_map> -#ifndef FORCE_NATIVE_ENDIANNESS -#include <boost/endian/conversion.hpp> -#endif - #ifdef USE_GOOGLE_HASHMAP #include <sparsehash/sparse_hash_map> template <class Key, class T> class hash_map : public google::sparse_hash_map<Key, T> { @@ -109,18 +105,23 @@ std::vector<coefficient_t> multiplicative_inverse_vector(const coefficient_t m) return inverse; } +template <typename T> inline void reverse_endianness(T & x) { + uint8_t * p = reinterpret_cast<uint8_t *>(&x); + std::reverse(p, p + sizeof(T)); +} + template <typename T> T read(std::istream& s) { T result; s.read(reinterpret_cast<char*>(&result), sizeof(T)); - #ifndef FORCE_NATIVE_ENDIANNESS - boost::endian::little_to_native_inplace(result); + #ifdef BIGENDIAN + reverse_endianness(result); #endif return result; } template <typename T> void write(std::ostream& s, T value) { - #ifndef FORCE_NATIVE_ENDIANNESS - boost::endian::native_to_little_inplace(value); + #ifdef BIGENDIAN + reverse_endianness(value); #endif s.write(reinterpret_cast<char*>(&value), sizeof(T)); } |