LikhachevAV / OOP2016

0 stars 0 forks source link

Замечания по MyArray #8

Open alexey-malov opened 7 years ago

alexey-malov commented 7 years ago
2>  1
2>c:/teaching/2016/ips/lihachev/oop2016/lab7/myarraytests/myarraytests.cpp(155): error : in "MyArray/can_use_iterators_to_loop_array/_forward_and_backward_using_rbegin_and_rend": check it->value == t has failed [1 != 3]
2>  0
2>c:/teaching/2016/ips/lihachev/oop2016/lab7/myarraytests/myarraytests.cpp(155): error : in "MyArray/can_use_iterators_to_loop_array/_forward_and_backward_using_rbegin_and_rend": check it->value == t has failed [0 != 4]
2>
2>c:\sdk\2012\boost_1_61_0\include\boost\test\tools\old\impl.hpp(107): warning C4389: '==': signed/unsigned mismatch
2>  c:\sdk\2012\boost_1_61_0\include\boost\test\tools\old\impl.hpp(130): note: see reference to function template instantiation 'boost::test_tools::assertion_result boost::test_tools::tt_detail::equal_impl<std::Left,Right>(const Left &,const Right &)' being compiled
2>          with
2>          [
2>              Left=std::size_t,
2>              Right=int
2>          ]
2>  c:\sdk\2012\boost_1_61_0\include\boost\test\tools\old\impl.hpp(145): note: see reference to function template instantiation 'boost::test_tools::assertion_result boost::test_tools::tt_detail::equal_impl_frwd::call_impl<std::Left,Right>(const Left &,const Right &,boost::mpl::false_) const' being compiled
2>          with
2>          [
2>              Left=std::size_t,
2>              Right=int
2>          ]
2>  c:\sdk\2012\boost_1_61_0\include\boost\test\tools\old\impl.hpp(92): note: see reference to function template instantiation 'boost::test_tools::assertion_result boost::test_tools::tt_detail::equal_impl_frwd::operator ()<std::Arg0,Arg1>(const Left &,const Right &) const' being compiled
2>          with
2>          [
2>              Arg0=std::size_t,
2>              Arg1=int,
2>              Left=std::size_t,
2>              Right=int
2>          ]
2>  c:\teaching\2016\ips\lihachev\oop2016\lab7\myarraytests\myarraytests.cpp(75): note: see reference to function template instantiation 'bool boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::equal_impl_frwd,std::size_t,int>(Pred,const boost::unit_test::lazy_ostream &,boost::unit_test::const_string,std::size_t,boost::test_tools::tt_detail::tool_level,boost::test_tools::tt_detail::check_type,const Arg0 &,const char *,const Arg1 &,const char *)' being compiled
2>          with
2>          [
2>              Pred=boost::test_tools::tt_detail::equal_impl_frwd,
2>              Arg0=std::size_t,
2>              Arg1=int
2>          ]
alexey-malov commented 7 years ago
new (m_end) T (value);
alexey-malov commented 7 years ago
    T& operator[](size_t index)
    {
        if (index >= GetSize())
        {
            throw std::out_of_range("Index out of range");
        }
        return *(m_begin + index);
    }
alexey-malov commented 7 years ago
    void Clear()
    {
        DeleteItems(m_begin, m_end);
        m_begin = nullptr;
        m_end = nullptr;
        m_endOfCapacity = nullptr;
    }
alexey-malov commented 7 years ago
alexey-malov commented 7 years ago
        T *p = static_cast<T*>(malloc(memSize));
alexey-malov commented 7 years ago
alexey-malov commented 7 years ago
template<typename T>
class CMyIterator : public std::iterator<std::bidirectional_iterator_tag, T>
alexey-malov commented 7 years ago
alexey-malov commented 7 years ago
alexey-malov commented 7 years ago

image

alexey-malov commented 7 years ago
alexey-malov commented 7 years ago
alexey-malov commented 7 years ago
2>c:\teaching\2016\ips\lihachev\oop2016\lab7\myarraytests\myarraytests.cpp(96): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
2>c:\teaching\2016\ips\lihachev\oop2016\lab7\myarraytests\myarraytests.cpp(139): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
2>c:\teaching\2016\ips\lihachev\oop2016\lab7\myarraytests\myarraytests.cpp(170): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
2>c:\teaching\2016\ips\lihachev\oop2016\lab7\myarraytests\myarraytests.cpp(171): warning C4267: 'initializing': conversion from 'size_t' to
alexey-malov commented 7 years ago
    void Clear()
    {
        DestroyItems(m_begin, m_end);
    }
alexey-malov commented 7 years ago
    void Resize()
    {
        m_end = m_endOfCapacity;
    }
alexey-malov commented 7 years ago
alexey-malov commented 7 years ago
alexey-malov commented 7 years ago
    CMyIterator& operator-(CMyIterator<T> const & other) const
    {
        return m_pointer - other.m_pointer;
    }
alexey-malov commented 7 years ago
    CMyIterator& operator=(const CMyIterator & it)
    {
        m_pointer = it.m_pointer;
        return *this;
    }
    T& operator[](ptrdiff_t index) const
    {
        return *(m_pointer + index);
    }

    CMyIterator& operator+=(ptrdiff_t n)
    { 
        m_ptr += n;
        return *this;
    }

    CMyIterator& operator-=(ptrdiff_t n)
    { 
        return *this += -n;
    }
    CMyIterator const operator+(ptrdiff_t n) const
    {
        return m_pointer + n;
    }

    CMyIterator& operator-(CMyIterator<T> const & other) const
    {
        return m_pointer - other.m_pointer;
    }

    bool operator<(CMyIterator const& other) const
    {
        return m_pointer < other.m_pointer;
    }

    bool operator>(CMyIterator const& other) const
    {
        return m_pointer > other.m_pointer;
    }

    bool operator<=(CMyIterator const& other) const
    {
        return m_pointer <= other.m_pointer;
    }

    bool operator>=(CMyIterator const& other) const
    {
        return m_pointer >= other.m_pointer;
    }

    CMyIterator operator-(ptrdiff_t n) const
    {
        return m_pointer - n;
    }