Change History (1)

comment:1 Changed 4 years ago by Артур Гулецкий (huletski)

Resolution: задача сдана
Status: assignedclosed

Замечания:

  • такой код не компилируется:
    my_array<bool, 10> a;
    a[0] = true;
    a[1] = a[0];
    assert(a[1]);
    
    {lab_13}[2624]$ make
    g++ -O2 -Wall -Werror -std=c++11 -Iinclude -c -MMD -o obj/main.o src/main.cpp
    In file included from src/main.cpp:1:
    include/my_array.h: In function ‘int main()’:
    include/my_array.h:65:23: error: ‘a’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
       65 |                 *cell &= ~(1 << bit);
          |                 ~~~~~~^~~~~~~~~~~~~~
    cc1plus: all warnings being treated as errors
    Makefile:17: recipe for target 'obj/main.o' failed
    make: *** [obj/main.o] Error 1
    
  • такой падает:
    my_array<bool, 10> a;
    a.fill(false);
    a[0] = true;
    a[1] = a[0];
    assert(a[1]);
    
  • и такой:
    my_array<bool, 10> a;
    a.fill(false);
    (a[1] = a[0]) = true;
    assert(a[1]);
    

my_array.h

  • 79: return (*this][index]; поможет избежать дублирования.

Баллы: 7.5.

Note: See TracTickets for help on using tickets.