This is an automated email from the ASF dual-hosted git repository. jmalkin pushed a commit to branch patch_for_rc4 in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git
commit 680ddc103443a0c5ada12e1ae9fa68496a3a34a3 Author: AlexanderSaydakov <[email protected]> AuthorDate: Mon Jun 1 10:29:31 2020 -0700 another attempt at MSVC compatibility --- theta/include/conditional_back_inserter.hpp | 9 +++++++++ theta/include/theta_a_not_b.hpp | 7 +++++++ theta/include/theta_a_not_b_impl.hpp | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/theta/include/conditional_back_inserter.hpp b/theta/include/conditional_back_inserter.hpp index e9b0590..9b33833 100644 --- a/theta/include/conditional_back_inserter.hpp +++ b/theta/include/conditional_back_inserter.hpp @@ -31,6 +31,15 @@ public: template<typename P> conditional_back_insert_iterator(Container& c, P&& p): std::back_insert_iterator<Container>(c), p(std::forward<P>(p)) {} + // MSVC seems to insist on having copy constructor and assignment + conditional_back_insert_iterator(const conditional_back_insert_iterator& other): + std::back_insert_iterator<Container>(other), p(other.p) {} + conditional_back_insert_iterator& operator=(const conditional_back_insert_iterator& other) { + std::back_insert_iterator<Container>::operator=(other); + p = other.p; + return *this; + } + conditional_back_insert_iterator& operator=(typename Container::const_reference value) { if (p(value)) std::back_insert_iterator<Container>::operator=(value); return *this; diff --git a/theta/include/theta_a_not_b.hpp b/theta/include/theta_a_not_b.hpp index 5287887..db66ac7 100644 --- a/theta/include/theta_a_not_b.hpp +++ b/theta/include/theta_a_not_b.hpp @@ -54,6 +54,13 @@ private: typedef typename std::allocator_traits<A>::template rebind_alloc<uint64_t> AllocU64; uint16_t seed_hash_; + class less_than { + public: + explicit less_than(uint64_t value): value(value) {} + bool operator()(uint64_t value) const { return value < this->value; } + private: + uint64_t value; + }; }; // alias with default allocator for convenience diff --git a/theta/include/theta_a_not_b_impl.hpp b/theta/include/theta_a_not_b_impl.hpp index 2ffca28..4343ee3 100644 --- a/theta/include/theta_a_not_b_impl.hpp +++ b/theta/include/theta_a_not_b_impl.hpp @@ -48,10 +48,10 @@ compact_theta_sketch_alloc<A> theta_a_not_b_alloc<A>::compute(const theta_sketch bool is_empty = a.is_empty(); if (b.get_num_retained() == 0) { - std::copy_if(a.begin(), a.end(), std::back_inserter(keys), [theta](uint64_t key) { return key < theta; }); + std::copy_if(a.begin(), a.end(), std::back_inserter(keys), less_than(theta)); } else { if (a.is_ordered() && b.is_ordered()) { // sort-based - std::set_difference(a.begin(), a.end(), b.begin(), b.end(), conditional_back_inserter(keys, [theta](uint64_t key) { return key < theta; })); + std::set_difference(a.begin(), a.end(), b.begin(), b.end(), conditional_back_inserter(keys, less_than(theta))); } else { // hash-based const uint8_t lg_size = lg_size_from_count(b.get_num_retained(), update_theta_sketch_alloc<A>::REBUILD_THRESHOLD); vector_u64<A> b_hash_table(1 << lg_size, 0); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
