Browse Source

Disable non-constexpr one-parameter constructor for Vector<1, T>.

It was clashing with the default "initializer-list" constructor, which
is constexpr. This constructor is also explicit, which makes it
impossible to e.g. return Vector<1, T> from function without explicitly
specifying name , while for Vector<2, T> it works:

    return {1, 2}; // works for Vector<2, int>
    return {1};    // doesn't work for Vector<1, int>
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
079a7be67d
  1. 4
      src/Math/Vector.h

4
src/Math/Vector.h

@ -103,7 +103,11 @@ template<size_t size, class T> class Vector {
* @brief Constructor
* @param value Value for all fields
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class U> inline explicit Vector(typename std::enable_if<std::is_same<T, U>::value && size != 1, U>::type value) {
#else
inline explicit Vector(T value) {
#endif
for(size_t i = 0; i != size; ++i)
_data[i] = value;
}

Loading…
Cancel
Save