diff --git a/NEWS.md b/NEWS.md index 0ee54640..88989b3d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,9 +4,9 @@ # s2 1.1.9 -* Implement serialization support for `s2_geography` vectors. This not only - allows data containing s2 geography to be safely saved and restored across - R sessions, but also enables using `s2` in parallel algorithms such as +* Implement serialization support for `s2_geography` vectors. This not only + allows data containing s2 geography to be safely saved and restored across + R sessions, but also enables using `s2` in parallel algorithms such as `mclapply()` (#283) * Fix code to help gcc-ubsan understand the region coverer (#275) * Inspect `S2_FORCE_BUNDLED_ABSEIL` in `conifigure`: if non-empty, any system diff --git a/configure b/configure index 266153c3..df34b0aa 100755 --- a/configure +++ b/configure @@ -15,6 +15,7 @@ PKG_RPM_NAME="openssl-devel" PKG_BREW_NAME="openssl" PKG_LIBS="-lssl -lcrypto" PKG_CFLAGS="" +PKG_CPPFLAGS="" # Use pkg-config if available pkg-config ${PKG_CONFIG_NAME} --atleast-version=1.0 2>/dev/null @@ -69,8 +70,12 @@ export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:`pwd`/tools/pkgconfig" echo "** Using PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" -if [ -z "$S2_FORCE_BUNDLED_ABSEIL" ] && [ "`uname -s`" = "Linux" ]; then - S2_FORCE_BUNDLED_ABSEIL=true +if [ -z "$S2_FORCE_BUNDLED_ABSEIL" ]; then + if [ "`uname -s`" = "Linux" ]; then + S2_FORCE_BUNDLED_ABSEIL=true + else + S2_FORCE_BUNDLED_ABSEIL=false + fi fi if [ "$S2_FORCE_BUNDLED_ABSEIL" = "false" ] && pkg-config absl_s2 --libs >/dev/null 2>/dev/null; then @@ -88,7 +93,7 @@ else # directory so that R CMD check does not inspects its static libraries for disallowed # symbols. Otherwise, we install into the package source (more conventional). if [ "$S2_FORCE_BUNDLED_ABSEIL" != "false" ]; then - CMAKE_INSTALL_PREFIX="/tmp/s2_absl_$$" + CMAKE_INSTALL_PREFIX="${TMPDIR:-/tmp}/s2_absl_$$" else CMAKE_INSTALL_PREFIX="`pwd`/tools/dist" fi @@ -116,13 +121,40 @@ else R_S2_ABSL_HOME="${CMAKE_INSTALL_PREFIX}" export PKG_CONFIG_PATH="${R_S2_PKG_CONFIG_PATH}:${PKG_CONFIG_PATH}" echo "** Using PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" - PKGCONFIG_LIBS=`pkg-config --libs absl_s2` + + # Resolve only against the pkg-config files for the copy we just built. The + # absl_s2 file is maintained by this package; its dependencies are installed + # alongside the vendored Abseil libraries. + R_S2_BUNDLED_PKG_CONFIG_PATH="${R_S2_PKG_CONFIG_PATH}:`pwd`/tools/pkgconfig" + PKGCONFIG_LIBS=`PKG_CONFIG_PATH="${R_S2_BUNDLED_PKG_CONFIG_PATH}" PKG_CONFIG_LIBDIR="${R_S2_BUNDLED_PKG_CONFIG_PATH}" pkg-config --libs absl_s2` if [ -z "${PKGCONFIG_LIBS}" ]; then echo "** Failed to resolve built vendored copy of Abseil using pkg-config" exit 1 fi - PKG_CFLAGS="-I${R_S2_ABSL_HOME}/include ${PKG_CFLAGS}" + # The vendored build contains static libraries. Replace its -labsl_* flags + # with exact archive paths so that the linker cannot select a system Abseil + # ahead of the copy whose headers and pkg-config files are used here. + R_S2_ABSL_LIBDIR=`PKG_CONFIG_PATH="${R_S2_BUNDLED_PKG_CONFIG_PATH}" PKG_CONFIG_LIBDIR="${R_S2_BUNDLED_PKG_CONFIG_PATH}" pkg-config --variable=libdir absl_base` + R_S2_STATIC_LIBS="" + for R_S2_LIB in ${PKGCONFIG_LIBS}; do + case "${R_S2_LIB}" in + -labsl*) + R_S2_ARCHIVE="${R_S2_ABSL_LIBDIR}/lib${R_S2_LIB#-l}.a" + if [ ! -f "${R_S2_ARCHIVE}" ]; then + echo "** Failed to find vendored Abseil archive ${R_S2_ARCHIVE}" + exit 1 + fi + R_S2_STATIC_LIBS="${R_S2_STATIC_LIBS} ${R_S2_ARCHIVE}" + ;; + *) + R_S2_STATIC_LIBS="${R_S2_STATIC_LIBS} ${R_S2_LIB}" + ;; + esac + done + PKGCONFIG_LIBS="${R_S2_STATIC_LIBS# }" + + PKG_CPPFLAGS="-I${R_S2_ABSL_HOME}/include" PKG_LIBS="${PKGCONFIG_LIBS} ${PKG_LIBS}" fi @@ -131,9 +163,9 @@ CXX17="`${R_HOME}/bin/R CMD config CXX17`" CXX17FLAGS=`"${R_HOME}"/bin/R CMD config CXX17FLAGS` CXX17STD=`"${R_HOME}"/bin/R CMD config CXX17STD` -echo "Testing Abseil configuration using PKG_CFLAGS=${PKG_CFLAGS}" +echo "Testing Abseil configuration using PKG_CPPFLAGS=${PKG_CPPFLAGS} PKG_CFLAGS=${PKG_CFLAGS}" -${CXX17} ${CPPFLAGS} ${PKG_CFLAGS} ${CXX17FLAGS} ${CXX17STD} -E tools/test_absl.cc >/dev/null 2>>configure.log +${CXX17} ${PKG_CPPFLAGS} ${CPPFLAGS} ${PKG_CFLAGS} ${CXX17FLAGS} ${CXX17STD} -E tools/test_absl.cc >/dev/null 2>>configure.log if [ $? -ne 0 ]; then echo "Test compile failed!" echo "------- Error ---------" @@ -151,9 +183,10 @@ fi echo "Using PKG_LIBS=$PKG_LIBS" echo "Using PKG_CFLAGS=$PKG_CFLAGS" +echo "Using PKG_CPPFLAGS=$PKG_CPPFLAGS" # Write to Makevars -sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" -e "s|@absl_home@|$R_S2_ABSL_HOME|" src/Makevars.in > src/Makevars +sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@cppflags@|$PKG_CPPFLAGS|" -e "s|@libs@|$PKG_LIBS|" -e "s|@absl_home@|$R_S2_ABSL_HOME|" src/Makevars.in > src/Makevars # Success exit 0 diff --git a/src/Makevars.in b/src/Makevars.in index cc316d98..a1fc3515 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -1,4 +1,4 @@ -PKG_CPPFLAGS = -I../src -DSTRICT_R_HEADERS -DRCPP_NO_MASK_RF_ERROR +PKG_CPPFLAGS = @cppflags@ -I../src -DSTRICT_R_HEADERS -DRCPP_NO_MASK_RF_ERROR PKG_LIBS = -Ls2 -ls2static @libs@ PKG_CXXFLAGS = @cflags@ -pthread diff --git a/src/s2/mutable_s2shape_index.cc b/src/s2/mutable_s2shape_index.cc index a05a35c1..065a867e 100644 --- a/src/s2/mutable_s2shape_index.cc +++ b/src/s2/mutable_s2shape_index.cc @@ -467,7 +467,7 @@ MutableS2ShapeIndex::MutableS2ShapeIndex(MutableS2ShapeIndex&& b) shapes_(std::move(b.shapes_)), cell_map_(std::move(b.cell_map_)), options_(std::move(b.options_)), - pending_additions_begin_(absl::exchange(b.pending_additions_begin_, 0)), + pending_additions_begin_(std::exchange(b.pending_additions_begin_, 0)), pending_removals_(std::move(b.pending_removals_)), index_status_(b.index_status_.exchange(FRESH, std::memory_order_relaxed)), mem_tracker_(std::move(b.mem_tracker_)) {} @@ -480,7 +480,7 @@ MutableS2ShapeIndex& MutableS2ShapeIndex::operator=(MutableS2ShapeIndex&& b) { shapes_ = std::move(b.shapes_); cell_map_ = std::move(b.cell_map_); options_ = std::move(b.options_); - pending_additions_begin_ = absl::exchange(b.pending_additions_begin_, 0); + pending_additions_begin_ = std::exchange(b.pending_additions_begin_, 0); pending_removals_ = std::move(b.pending_removals_); index_status_.store( b.index_status_.exchange(FRESH, std::memory_order_relaxed), diff --git a/src/s2/s2cell_iterator.h b/src/s2/s2cell_iterator.h index c77d62c2..1f8fb01f 100644 --- a/src/s2/s2cell_iterator.h +++ b/src/s2/s2cell_iterator.h @@ -17,8 +17,8 @@ #define S2_S2CELL_ITERATOR_H_ #include +#include -#include "absl/meta/type_traits.h" #include "s2/s2cell_id.h" // Possible relationships between two S2CellIds in an index. @@ -86,7 +86,7 @@ class S2CellIterator { // "We require an object implementing the S2CellIterator API."); // } template - using ImplementedBy = std::is_convertible*, S2CellIterator*>; + using ImplementedBy = std::is_convertible*, S2CellIterator*>; S2CellIterator() = default; virtual ~S2CellIterator() = default; diff --git a/src/s2/s2cell_range_iterator.h b/src/s2/s2cell_range_iterator.h index c1188c75..0777b735 100644 --- a/src/s2/s2cell_range_iterator.h +++ b/src/s2/s2cell_range_iterator.h @@ -16,7 +16,7 @@ #ifndef S2_S2CELL_RANGE_ITERATOR_H_ #define S2_S2CELL_RANGE_ITERATOR_H_ -#include "absl/meta/type_traits.h" +#include #include "s2/s2cell_id.h" #include "s2/s2cell_iterator.h" #include "s2/s2shape_index.h" @@ -119,7 +119,7 @@ template {}, bool>::type = true> auto MakeS2CellRangeIterator(Iterator&& iter) { - return S2CellRangeIterator>( + return S2CellRangeIterator>( std::forward(iter)); } diff --git a/src/s2/s2lax_loop_shape.cc b/src/s2/s2lax_loop_shape.cc index 7fd3cf3c..79d02f8f 100644 --- a/src/s2/s2lax_loop_shape.cc +++ b/src/s2/s2lax_loop_shape.cc @@ -35,12 +35,12 @@ using ReferencePoint = S2Shape::ReferencePoint; S2LaxLoopShape::S2LaxLoopShape(S2LaxLoopShape&& other) : S2Shape(std::move(other)), - num_vertices_(absl::exchange(other.num_vertices_, 0)), + num_vertices_(std::exchange(other.num_vertices_, 0)), vertices_(std::move(other.vertices_)) {} S2LaxLoopShape& S2LaxLoopShape::operator=(S2LaxLoopShape&& other) { S2Shape::operator=(static_cast(other)); - num_vertices_ = absl::exchange(other.num_vertices_, 0); + num_vertices_ = std::exchange(other.num_vertices_, 0); vertices_ = std::move(other.vertices_); return *this; } @@ -92,14 +92,14 @@ S2Shape::ReferencePoint S2LaxLoopShape::GetReferencePoint() const { S2VertexIdLaxLoopShape::S2VertexIdLaxLoopShape(S2VertexIdLaxLoopShape&& other) : S2Shape(std::move(other)), - num_vertices_(absl::exchange(other.num_vertices_, 0)), + num_vertices_(std::exchange(other.num_vertices_, 0)), vertex_ids_(std::move(other.vertex_ids_)), vertex_array_(std::move(other.vertex_array_)) {} S2VertexIdLaxLoopShape& S2VertexIdLaxLoopShape::operator=( S2VertexIdLaxLoopShape&& other) { S2Shape::operator=(static_cast(other)); - num_vertices_ = absl::exchange(other.num_vertices_, 0); + num_vertices_ = std::exchange(other.num_vertices_, 0); vertex_ids_ = std::move(other.vertex_ids_); vertex_array_ = std::move(other.vertex_array_); return *this; diff --git a/src/s2/s2lax_polygon_shape.cc b/src/s2/s2lax_polygon_shape.cc index de0b5f44..69e7adac 100644 --- a/src/s2/s2lax_polygon_shape.cc +++ b/src/s2/s2lax_polygon_shape.cc @@ -75,9 +75,9 @@ S2LaxPolygonShape::S2LaxPolygonShape(const S2Polygon& polygon) { S2LaxPolygonShape::S2LaxPolygonShape(S2LaxPolygonShape&& b) : S2Shape(std::move(b)), - num_loops_(absl::exchange(b.num_loops_, 0)), + num_loops_(std::exchange(b.num_loops_, 0)), prev_loop_(b.prev_loop_.exchange(0, std::memory_order_relaxed)), - num_vertices_(absl::exchange(b.num_vertices_, 0)), + num_vertices_(std::exchange(b.num_vertices_, 0)), vertices_(std::move(b.vertices_)), loop_starts_(std::move(b.loop_starts_)) {} @@ -88,10 +88,10 @@ S2LaxPolygonShape& S2LaxPolygonShape::operator=(S2LaxPolygonShape&& b) { // move any of its private state. This is a little odd since b is in a // half-moved state after calling but is ultimately safe. S2Shape::operator=(static_cast(b)); - num_loops_ = absl::exchange(b.num_loops_, 0); + num_loops_ = std::exchange(b.num_loops_, 0); prev_loop_.store(b.prev_loop_.exchange(0, memory_order_relaxed), memory_order_relaxed); - num_vertices_ = absl::exchange(b.num_vertices_, 0); + num_vertices_ = std::exchange(b.num_vertices_, 0); vertices_ = std::move(b.vertices_); loop_starts_ = std::move(b.loop_starts_); return *this; @@ -255,7 +255,7 @@ S2Shape::Chain S2LaxPolygonShape::chain(int i) const { EncodedS2LaxPolygonShape::EncodedS2LaxPolygonShape(EncodedS2LaxPolygonShape&& b) : S2Shape(std::move(b)), - num_loops_(absl::exchange(b.num_loops_, 0)), + num_loops_(std::exchange(b.num_loops_, 0)), prev_loop_(b.prev_loop_.exchange(0, std::memory_order_relaxed)), vertices_(std::move(b.vertices_)), loop_starts_(std::move(b.loop_starts_)) {} @@ -266,7 +266,7 @@ EncodedS2LaxPolygonShape& EncodedS2LaxPolygonShape::operator=( // move any of its private state. This is a little odd since b is in a // half-moved state after calling but is ultimately safe. S2Shape::operator=(static_cast(b)); - num_loops_ = absl::exchange(b.num_loops_, 0); + num_loops_ = std::exchange(b.num_loops_, 0); prev_loop_.store(b.prev_loop_.exchange(0, std::memory_order_relaxed), std::memory_order_relaxed); vertices_ = std::move(b.vertices_); diff --git a/src/s2/s2lax_polyline_shape.cc b/src/s2/s2lax_polyline_shape.cc index a156e533..75d1ebbe 100644 --- a/src/s2/s2lax_polyline_shape.cc +++ b/src/s2/s2lax_polyline_shape.cc @@ -37,12 +37,12 @@ using std::make_unique; S2LaxPolylineShape::S2LaxPolylineShape(S2LaxPolylineShape&& other) : S2Shape(std::move(other)), - num_vertices_(absl::exchange(other.num_vertices_, 0)), + num_vertices_(std::exchange(other.num_vertices_, 0)), vertices_(std::move(other.vertices_)) {} S2LaxPolylineShape& S2LaxPolylineShape::operator=(S2LaxPolylineShape&& other) { S2Shape::operator=(static_cast(other)); - num_vertices_ = absl::exchange(other.num_vertices_, 0); + num_vertices_ = std::exchange(other.num_vertices_, 0); vertices_ = std::move(other.vertices_); return *this; } diff --git a/src/s2/s2loop.cc b/src/s2/s2loop.cc index babe1ecc..425601fd 100644 --- a/src/s2/s2loop.cc +++ b/src/s2/s2loop.cc @@ -110,8 +110,8 @@ S2Loop::S2Loop() { #ifndef SWIG S2Loop::S2Loop(S2Loop&& b) : S2Region(std::move(b)), - depth_(absl::exchange(b.depth_, 0)), - num_vertices_(absl::exchange(b.num_vertices_, 0)), + depth_(std::exchange(b.depth_, 0)), + num_vertices_(std::exchange(b.num_vertices_, 0)), vertices_(std::move(b.vertices_)), s2debug_override_(std::move(b.s2debug_override_)), origin_inside_(std::move(b.origin_inside_)), @@ -129,8 +129,8 @@ S2Loop::S2Loop(S2Loop&& b) S2Loop& S2Loop::operator=(S2Loop&& b) { S2Region::operator=(static_cast(b)); - depth_ = absl::exchange(b.depth_, 0); - num_vertices_ = absl::exchange(b.num_vertices_, 0); + depth_ = std::exchange(b.depth_, 0); + num_vertices_ = std::exchange(b.num_vertices_, 0); vertices_ = std::move(b.vertices_); s2debug_override_ = std::move(b.s2debug_override_); origin_inside_ = std::move(b.origin_inside_); diff --git a/src/s2/s2polygon.cc b/src/s2/s2polygon.cc index f90606cd..6ff28b6f 100644 --- a/src/s2/s2polygon.cc +++ b/src/s2/s2polygon.cc @@ -138,8 +138,8 @@ S2Polygon::S2Polygon(S2Polygon&& b) loops_(std::move(b.loops_)), s2debug_override_(std::move(b.s2debug_override_)), error_inconsistent_loop_orientations_( - absl::exchange(b.error_inconsistent_loop_orientations_, 0)), - num_vertices_(absl::exchange(b.num_vertices_, 0)), + std::exchange(b.error_inconsistent_loop_orientations_, 0)), + num_vertices_(std::exchange(b.num_vertices_, 0)), unindexed_contains_calls_( b.unindexed_contains_calls_.exchange(0, std::memory_order_relaxed)), bound_(std::move(b.bound_)), @@ -161,8 +161,8 @@ S2Polygon& S2Polygon::operator=(S2Polygon&& b) { loops_ = std::move(b.loops_); s2debug_override_ = std::move(b.s2debug_override_); error_inconsistent_loop_orientations_ = - absl::exchange(b.error_inconsistent_loop_orientations_, 0); - num_vertices_ = absl::exchange(b.num_vertices_, 0); + std::exchange(b.error_inconsistent_loop_orientations_, 0); + num_vertices_ = std::exchange(b.num_vertices_, 0); unindexed_contains_calls_.store( b.unindexed_contains_calls_.exchange(0, std::memory_order_relaxed), std::memory_order_relaxed); diff --git a/src/s2/s2polyline.cc b/src/s2/s2polyline.cc index 4a245a98..ee50e745 100644 --- a/src/s2/s2polyline.cc +++ b/src/s2/s2polyline.cc @@ -78,13 +78,13 @@ S2Polyline::S2Polyline() S2Polyline::S2Polyline(S2Polyline&& other) : s2debug_override_(other.s2debug_override_), - num_vertices_(absl::exchange(other.num_vertices_, 0)), + num_vertices_(std::exchange(other.num_vertices_, 0)), vertices_(std::move(other.vertices_)) { } S2Polyline& S2Polyline::operator=(S2Polyline&& other) { s2debug_override_ = other.s2debug_override_; - num_vertices_ = absl::exchange(other.num_vertices_, 0); + num_vertices_ = std::exchange(other.num_vertices_, 0); vertices_ = std::move(other.vertices_); return *this; } diff --git a/src/s2/s2shape_index.h b/src/s2/s2shape_index.h index fe4a2dff..1e31b78d 100644 --- a/src/s2/s2shape_index.h +++ b/src/s2/s2shape_index.h @@ -305,7 +305,7 @@ class S2ShapeIndex { // "We require an S2ShapeIndex."); // } template - using ImplementedBy = std::is_convertible*, S2ShapeIndex*>; + using ImplementedBy = std::is_convertible*, S2ShapeIndex*>; virtual ~S2ShapeIndex() = default; diff --git a/src/s2/util/coding/coder.cc b/src/s2/util/coding/coder.cc index 157968e0..abaf40a4 100644 --- a/src/s2/util/coding/coder.cc +++ b/src/s2/util/coding/coder.cc @@ -32,18 +32,18 @@ #include "s2/base/port.h" Encoder::Encoder(Encoder&& other) - : buf_(absl::exchange(other.buf_, nullptr)), - limit_(absl::exchange(other.limit_, nullptr)), - underlying_buffer_(absl::exchange(other.underlying_buffer_, nullptr)), - orig_(absl::exchange(other.orig_, nullptr)) {} + : buf_(std::exchange(other.buf_, nullptr)), + limit_(std::exchange(other.limit_, nullptr)), + underlying_buffer_(std::exchange(other.underlying_buffer_, nullptr)), + orig_(std::exchange(other.orig_, nullptr)) {} Encoder& Encoder::operator=(Encoder&& other) { if (this == &other) return *this; if (ensure_allowed()) DeleteBuffer(underlying_buffer_, capacity()); - buf_ = absl::exchange(other.buf_, nullptr); - limit_ = absl::exchange(other.limit_, nullptr); - underlying_buffer_ = absl::exchange(other.underlying_buffer_, nullptr); - orig_ = absl::exchange(other.orig_, nullptr); + buf_ = std::exchange(other.buf_, nullptr); + limit_ = std::exchange(other.limit_, nullptr); + underlying_buffer_ = std::exchange(other.underlying_buffer_, nullptr); + orig_ = std::exchange(other.orig_, nullptr); return *this; } diff --git a/src/s2/util/coding/coder.h b/src/s2/util/coding/coder.h index e209b5ae..3567a59b 100644 --- a/src/s2/util/coding/coder.h +++ b/src/s2/util/coding/coder.h @@ -158,7 +158,7 @@ class Encoder { S2_DCHECK_LE(enc->buf_, enc->limit_); } - char* skip(ptrdiff_t N) { return absl::exchange(p, p + N); } + char* skip(ptrdiff_t N) { return std::exchange(p, p + N); } void put8(unsigned char v) { *p++ = v; } void put16(uint16 v) { LittleEndian::Store16(skip(2), v); } @@ -490,11 +490,11 @@ inline void DecoderExtensions::FillArray(Decoder* array, int num_decoders) { // This is an optimization based on the fact that Decoder(nullptr, 0) sets all // structure bytes to 0. This is valid because Decoder is TriviallyCopyable // (https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable). - static_assert(absl::is_trivially_copy_constructible::value, + static_assert(std::is_trivially_copy_constructible::value, "Decoder must be trivially copy-constructible"); - static_assert(absl::is_trivially_copy_assignable::value, + static_assert(std::is_trivially_copy_assignable::value, "Decoder must be trivially copy-assignable"); - static_assert(absl::is_trivially_destructible::value, + static_assert(std::is_trivially_destructible::value, "Decoder must be trivially destructible"); // For R On Windows, this line gives install warning diff --git a/src/s2/util/gtl/compact_array.h b/src/s2/util/gtl/compact_array.h index 45529730..27ccbcd4 100644 --- a/src/s2/util/gtl/compact_array.h +++ b/src/s2/util/gtl/compact_array.h @@ -51,7 +51,6 @@ #include #include "absl/base/macros.h" -#include "absl/meta/type_traits.h" #include "s2/base/integral_types.h" #include "s2/base/logging.h" @@ -359,7 +358,7 @@ class compact_array_base { // Destroying elements on shrinking resize isn't a concern, since the // value_type must be trivially destructible. if (n > size() && - !absl::is_trivially_default_constructible::value) { + !std::is_trivially_default_constructible::value) { // Increasing size would expose unconstructed elements. value_type *new_end = Array() + n; for (value_type *p = Array() + size(); p != new_end; ++p) @@ -520,9 +519,9 @@ class compact_array_base { typedef typename std::iterator_traits::iterator_category Cat; range_insert(p, first, last, Cat()); } - static_assert(absl::is_trivially_copy_constructible::value && - absl::is_trivially_copy_assignable::value && - absl::is_trivially_destructible::value, + static_assert(std::is_trivially_copy_constructible::value && + std::is_trivially_copy_assignable::value && + std::is_trivially_destructible::value, "Requires trivial copy, assignment, and destructor."); }; diff --git a/src/s2/util/math/vector.h b/src/s2/util/math/vector.h index 8bd3338f..9dba75bd 100644 --- a/src/s2/util/math/vector.h +++ b/src/s2/util/math/vector.h @@ -30,6 +30,7 @@ #include #include #include +#include #include "s2/base/integral_types.h" #include "s2/base/logging.h" @@ -59,7 +60,7 @@ class BasicVector { typedef typename std::conditional::value, double, T>::type FloatType; - using IdxSeqN = typename absl::make_index_sequence; + using IdxSeqN = typename std::make_index_sequence; template static auto Reduce(F f, As*... as) -> decltype(f(as[I]...)) { @@ -67,7 +68,7 @@ class BasicVector { } template - static R GenerateEach(absl::index_sequence, F f, As*... as) { + static R GenerateEach(std::index_sequence, F f, As*... as) { return R(Reduce(std::move(f), as...)...); } @@ -308,28 +309,28 @@ class BasicVector { static void Ignore(std::initializer_list) {} template - static T Dot(T sum, const T* a, const T* b, absl::index_sequence) { + static T Dot(T sum, const T* a, const T* b, std::index_sequence) { Ignore({(sum += a[Is] * b[Is], true)...}); return sum; } template - static void PlusEq(T* a, const T* b, absl::index_sequence) { + static void PlusEq(T* a, const T* b, std::index_sequence) { Ignore({(a[Is] += b[Is], true)...}); } template - static void MinusEq(T* a, const T* b, absl::index_sequence) { + static void MinusEq(T* a, const T* b, std::index_sequence) { Ignore({(a[Is] -= b[Is], true)...}); } template - static void MulEq(T* a, T b, absl::index_sequence) { + static void MulEq(T* a, T b, std::index_sequence) { Ignore({(a[Is] *= b, true)...}); } template - static void DivEq(T* a, T b, absl::index_sequence) { + static void DivEq(T* a, T b, std::index_sequence) { Ignore({(a[Is] /= b, true)...}); } };