From 46a2487c73a349064b7a0e2f9992ee23b8a28b5c Mon Sep 17 00:00:00 2001 From: Kim Laine Date: Sat, 30 May 2020 22:30:22 -0700 Subject: [PATCH] Fixed bug in IterTuple value_type --- native/src/seal/evaluator.cpp | 8 +++---- native/src/seal/util/iterator.h | 37 ++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/native/src/seal/evaluator.cpp b/native/src/seal/evaluator.cpp index 60bfba71a..fec767d3a 100644 --- a/native/src/seal/evaluator.cpp +++ b/native/src/seal/evaluator.cpp @@ -323,14 +323,14 @@ namespace seal // This lambda function takes as input an IterTuple with three components: // - // 1. ConstRNSIter to read an input polynomial from + // 1. (Const)RNSIter to read an input polynomial from // 2. RNSIter for the output in base q // 3. RNSIter for the output in base Bsk // // It performs steps (1)-(3) of the BEHZ multiplication (see above) on the given input polynomial (given as an // RNSIter or ConstRNSIter) and writes the results in base q and base Bsk to the given output // iterators. - auto behz_extend_base_convert_to_ntt = [&](IterTuple I) { + auto behz_extend_base_convert_to_ntt = [&](auto I) { // Make copy of input polynomial (in base q) and convert to NTT form // Lazy reduction set_poly(get<0>(I), coeff_count, base_q_size, get<1>(I)); @@ -607,13 +607,13 @@ namespace seal // This lambda function takes as input an IterTuple with three components: // - // 1. ConstRNSIter to read an input polynomial from + // 1. (Const)RNSIter to read an input polynomial from // 2. RNSIter for the output in base q // 3. RNSIter for the output in base Bsk // // It performs steps (1)-(3) of the BEHZ multiplication on the given input polynomial (given as an RNSIter // or ConstRNSIter) and writes the results in base q and base Bsk to the given output iterators. - auto behz_extend_base_convert_to_ntt = [&](IterTuple I) { + auto behz_extend_base_convert_to_ntt = [&](auto I) { // Make copy of input polynomial (in base q) and convert to NTT form // Lazy reduction set_poly(get<0>(I), coeff_count, base_q_size, get<1>(I)); diff --git a/native/src/seal/util/iterator.h b/native/src/seal/util/iterator.h index 285a1d91d..9b6f2b1c6 100644 --- a/native/src/seal/util/iterator.h +++ b/native/src/seal/util/iterator.h @@ -1573,6 +1573,24 @@ namespace seal } }; + namespace iterator_internal + { + template + struct extend_iter_tuple; + + template + struct extend_iter_tuple> + { + using type = IterTuple; + }; + + template + struct extend_iter_tuple + { + using type = IterTuple; + }; + } + template class IterTuple : public SEALIterBase { @@ -1584,9 +1602,9 @@ namespace seal using self_type = IterTuple; // Standard iterator typedefs - using value_type = IterTuple< + using value_type = typename iterator_internal::extend_iter_tuple< typename std::iterator_traits::value_type, - typename std::iterator_traits>::value_type...>; + typename std::iterator_traits>::value_type>::type; using pointer = void; using reference = const value_type &; using iterator_category = std::random_access_iterator_tag; @@ -1970,21 +1988,6 @@ namespace seal return iterator_internal::GetHelperStruct::apply(it); } - template - struct extend_iter_tuple; - - template - struct extend_iter_tuple> - { - using type = IterTuple; - }; - - template - struct extend_iter_tuple - { - using type = IterTuple; - }; - template struct iter_type< std::void_t<