*/
#include "buffer_tmpl.hpp"
+#include "config.hpp"
#include <cstddef>
#include <iterator>
protozero_assert(from <= buffer->size());
protozero_assert(to <= buffer->size());
protozero_assert(from <= to);
- buffer->erase(std::next(buffer->begin(), from), std::next(buffer->begin(), to));
+ buffer->erase(std::next(buffer->begin(), static_cast<std::string::iterator::difference_type>(from)),
+ std::next(buffer->begin(), static_cast<std::string::iterator::difference_type>(to)));
}
static char* at_pos(std::string* buffer, std::size_t pos) {
*/
#include "buffer_tmpl.hpp"
+#include "config.hpp"
#include <cstddef>
#include <iterator>
protozero_assert(from <= buffer->size());
protozero_assert(to <= buffer->size());
protozero_assert(from <= to);
- buffer->erase(std::next(buffer->begin(), from), std::next(buffer->begin(), to));
+ buffer->erase(std::next(buffer->begin(), static_cast<std::string::iterator::difference_type>(from)),
+ std::next(buffer->begin(), static_cast<std::string::iterator::difference_type>(to)));
}
static char* at_pos(std::vector<char>* buffer, std::size_t pos) {
#include "config.hpp"
#include <cstdint>
+#include <cstring>
namespace protozero {
namespace detail {
/// byteswap the data pointed to by ptr in-place.
inline void byteswap_inplace(float* ptr) noexcept {
- auto* bptr = reinterpret_cast<uint32_t*>(ptr);
- *bptr = detail::byteswap_impl(*bptr);
+ static_assert(sizeof(float) == 4, "Expecting four byte float");
+
+ uint32_t tmp = 0;
+ std::memcpy(&tmp, ptr, 4);
+ tmp = detail::byteswap_impl(tmp); // uint32 overload
+ std::memcpy(ptr, &tmp, 4);
}
/// byteswap the data pointed to by ptr in-place.
inline void byteswap_inplace(double* ptr) noexcept {
- auto* bptr = reinterpret_cast<uint64_t*>(ptr);
- *bptr = detail::byteswap_impl(*bptr);
+ static_assert(sizeof(double) == 8, "Expecting eight byte double");
+
+ uint64_t tmp = 0;
+ std::memcpy(&tmp, ptr, 8);
+ tmp = detail::byteswap_impl(tmp); // uint64 overload
+ std::memcpy(ptr, &tmp, 8);
}
namespace detail {
#define PROTOZERO_VERSION_MINOR 7
/// The patch number
-#define PROTOZERO_VERSION_PATCH 0
+#define PROTOZERO_VERSION_PATCH 1
/// The complete version number
#define PROTOZERO_VERSION_CODE (PROTOZERO_VERSION_MAJOR * 10000 + PROTOZERO_VERSION_MINOR * 100 + PROTOZERO_VERSION_PATCH)
/// Version number as string
-#define PROTOZERO_VERSION_STRING "1.7.0"
+#define PROTOZERO_VERSION_STRING "1.7.1"
#endif // PROTOZERO_VERSION_HPP