mirror of https://github.com/aria2/aria2
2009-02-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added operator T* * src/array_fun.h * test/array_funTest.ccpull/1/head
parent
5547b3a5ed
commit
1c46a26ae6
|
@ -1,3 +1,9 @@
|
||||||
|
2009-02-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Added operator T*
|
||||||
|
* src/array_fun.h
|
||||||
|
* test/array_funTest.cc
|
||||||
|
|
||||||
2009-02-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-02-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Use dynamically allocated char array to detect memory access
|
Use dynamically allocated char array to detect memory access
|
||||||
|
|
|
@ -250,6 +250,16 @@ public:
|
||||||
{
|
{
|
||||||
return _array[index];
|
return _array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator T*()
|
||||||
|
{
|
||||||
|
return _array;
|
||||||
|
}
|
||||||
|
|
||||||
|
operator const T*() const
|
||||||
|
{
|
||||||
|
return _array;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -92,6 +92,10 @@ static void arrayPtrConst(const array_ptr<struct array_funTest::X>& ax)
|
||||||
CPPUNIT_ASSERT_EQUAL(99, ax[2].m);
|
CPPUNIT_ASSERT_EQUAL(99, ax[2].m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void arrayPtrCast(struct array_funTest::X* x) {}
|
||||||
|
|
||||||
|
static void arrayPtrConstCast(const struct array_funTest::X* x) {}
|
||||||
|
|
||||||
void array_funTest::testArrayPtr()
|
void array_funTest::testArrayPtr()
|
||||||
{
|
{
|
||||||
array_ptr<struct X> ax(new struct X[10]);
|
array_ptr<struct X> ax(new struct X[10]);
|
||||||
|
@ -100,6 +104,9 @@ void array_funTest::testArrayPtr()
|
||||||
CPPUNIT_ASSERT_EQUAL(100, ax[3].m);
|
CPPUNIT_ASSERT_EQUAL(100, ax[3].m);
|
||||||
CPPUNIT_ASSERT_EQUAL(99, ax[2].m);
|
CPPUNIT_ASSERT_EQUAL(99, ax[2].m);
|
||||||
arrayPtrConst(ax);
|
arrayPtrConst(ax);
|
||||||
|
|
||||||
|
arrayPtrCast(ax);
|
||||||
|
arrayPtrConstCast(ax);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
Loading…
Reference in New Issue