Opened 4 years ago

Closed 4 years ago

#1015 closed ожидаются исправления (задача сдана)

WW #15

Reported by: Alexander Morozov Owned by: Egor Suvorov
Component: WW_linq Version: 1.0
Keywords: Cc:

Description


Change History (1)

comment:1 Changed 4 years ago by Egor Suvorov

Resolution: задача сдана
Status: assignedclosed
Type: ожидается проверкаожидаются исправления

Можно договориться и дорешать на баллы.

Корректность: 6/7

  • Не компилируется с предупреждениями (это стиль в том числе):
       In file included from src/linq_tests.cpp:1:
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:133:16: error: 'cache' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
      virtual void cache() = 0;
                   ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:189:40: note: in instantiation of template class 'linq::impl::nonroot_enumerator<int, int>' requested here
    class select_enumerator final : public nonroot_enumerator<T, U> {
                                           ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:48:12: note: in instantiation of template class 'linq::impl::select_enumerator<int, int, linq::impl::ref_function<(lambda at src/linq_tests.cpp:89:22)> >' requested here
        return select_enumerator<U, T, ref_function<F>>(*this,
               ^
    src/linq_tests.cpp:89:15: note: in instantiation of function template specialization 'linq::impl::enumerator<int>::select<int, (lambda at src/linq_tests.cpp:89:22)>' requested here
                 .select([](int x) { return x * x; })
                  ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:88:16: note: overridden virtual function is here
      virtual void cache() = 0;
                   ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:133:16: error: 'cache' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
      virtual void cache() = 0;
                   ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:189:40: note: in instantiation of template class 'linq::impl::nonroot_enumerator<double, int>' requested here
    class select_enumerator final : public nonroot_enumerator<T, U> {
                                           ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:48:12: note: in instantiation of template class 'linq::impl::select_enumerator<double, int, linq::impl::ref_function<(lambda at src/linq_tests.cpp:113:43)> >' requested here
        return select_enumerator<U, T, ref_function<F>>(*this,
               ^
    src/linq_tests.cpp:113:28: note: in instantiation of function template specialization 'linq::impl::enumerator<int>::select<double, (lambda at src/linq_tests.cpp:113:43)>' requested here
      auto res = to_stream(xs).select<double>([](int x) { return std::sqrt(x); })
                               ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:88:16: note: overridden virtual function is here
      virtual void cache() = 0;
                   ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:133:16: error: 'cache' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
      virtual void cache() = 0;
                   ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:189:40: note: in instantiation of template class 'linq::impl::nonroot_enumerator<std::__1::basic_string<char>, int>' requested here
    class select_enumerator final : public nonroot_enumerator<T, U> {
                                           ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:48:12: note: in instantiation of template class 'linq::impl::select_enumerator<std::__1::basic_string<char>, int, linq::impl::ref_function<(lambda at src/linq_tests.cpp:439:37)> >' requested here
        return select_enumerator<U, T, ref_function<F>>(*this,
               ^
    src/linq_tests.cpp:439:17: note: in instantiation of function template specialization 'linq::impl::enumerator<int>::select<std::__1::basic_string<char>, (lambda at src/linq_tests.cpp:439:37)>' requested here
                   .select<std::string>([](int x) { return std::to_string(x); })
                    ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:88:16: note: overridden virtual function is here
      virtual void cache() = 0;
                   ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:133:16: error: 'cache' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
      virtual void cache() = 0;
                   ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:189:40: note: in instantiation of template class 'linq::impl::nonroot_enumerator<char, int>' requested here
    class select_enumerator final : public nonroot_enumerator<T, U> {
                                           ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:48:12: note: in instantiation of template class 'linq::impl::select_enumerator<char, int, linq::impl::ref_function<(lambda at src/linq_tests.cpp:463:43)> >' requested here
        return select_enumerator<U, T, ref_function<F>>(*this,
               ^
    src/linq_tests.cpp:463:30: note: in instantiation of function template specialization 'linq::impl::enumerator<int>::select<char, (lambda at src/linq_tests.cpp:463:43)>' requested here
        auto res = to_stream(xs).select<char>([](int x) {
                                 ^
    ../../../cpp19/morozov.aleksandr/lab_15/include/linq.hpp:88:16: note: overridden virtual function is here
      virtual void cache() = 0;
                   ^
    4 errors generated.
    
  • При работе с drop можно случайно разыменовать и скопировать пропущенные элементы. Кажется, это вылезает из самой архитектуры :(


Стиль 1/3:

  • Не надо делать , в циклах вместо {}. Смотрю на drop_enumerator. Это не читается.
  • Не хватает слов explicit (оператор), noexcept, override, и rvalue-ref-qualifier у методов.
    • При этом если есть override, то virtual надо убрать.
  • Не хватает виртуального деструктора в полиморфном классе enumerator. Конкретно в этой задаче это ни на что не влияет, но привычка полезная.
  • У enumerator стоит запретить копирование и перемещение — это точно ошибки. Перемещение можно запрещать, начиная с C++17 из-за copy elision.
  • to_vector лучше через copy_to+back_inserter
  • ref_function — это не std::reference_wrapper, случаем? Понятно, что тогда про него я ещё не рассказывал, но сейчас актуально.
    • Лайк.
  • check_parent ещё и как-то меняет состояние объекта, из названия неочевидно. К тому же местами не используется.
  • cache лучше переименовать в fetch_next_element/find_`, иначе неясно, что именно кэшируется, пока не разобрался во внутренней логике.
  • take_enumerator: какое-то дублирование кода внутри.
  • until_enumerator/where_enumerator — как-то многовато ифов и циклов, мне кажется.
Note: See TracTickets for help on using tickets.