Browse Source

Revert "Math: don't allow *::data() to be called on rvalues."

The pointer conversion can be done only explicitly, thus the users will
always know what they are doing. With that change, perfectly valid
things like this couldn't be done (the result of a + b is kept until the
semicolon):

    Vector3 a, b;
    void foo(float* data);
    foo((a + b).data());

Moreover this conversion wasn't even properly tested, leading to issues
as in mosra/corrade@781f5df38a7b1b366f3de477dd5fe641eca6ed20.

This reverts commit add989703e.
pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
cf3ae0eee7
  1. 16
      src/Math/RectangularMatrix.h
  2. 16
      src/Math/Vector.h

16
src/Math/RectangularMatrix.h

@ -164,20 +164,8 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
*
* @see operator[]
*/
T* data()
#ifndef CORRADE_GCC47_COMPATIBILITY
&
#endif
{ return _data[0].data(); }
/** @overload */
constexpr const T* data()
#ifndef CORRADE_GCC47_COMPATIBILITY
const &
#else
const
#endif
{ return _data[0].data(); }
T* data() { return _data[0].data(); }
constexpr const T* data() const { return _data[0].data(); } /**< @overload */
/**
* @brief %Matrix column

16
src/Math/Vector.h

@ -184,20 +184,8 @@ template<std::size_t size, class T> class Vector {
*
* @see operator[]()
*/
T* data()
#ifndef CORRADE_GCC47_COMPATIBILITY
&
#endif
{ return _data; }
/** @overload */
constexpr const T* data()
#ifndef CORRADE_GCC47_COMPATIBILITY
const &
#else
const
#endif
{ return _data; }
T* data() { return _data; }
constexpr const T* data() const { return _data; } /**< @overload */
/**
* @brief Value at given position

Loading…
Cancel
Save