V
Valeriu Catina
Hi,
g++ gives the next error messages
test.cpp: In function 'int main()':
test.cpp:53: error: invalid conversion from 'int' to 'SmallVectorNoInit
(*)()'
test.cpp:53: error: initializing argument 1 of 'SmallVector<double, 4>
sv(SmallVectorNoInit (*)())'
test.cpp:53: error: no match for 'operator=' in 'sv(SmallVectorNoInit
(*)())() = 1.0e+0'
test.cpp:6: note: candidates are: SmallVector<double, 4>&
SmallVector<double, 4>:perator=(const SmallVector<double, 4>&)
when it compiles the code below:
////////////////////////////////////////////////
struct SmallVectorNoInit {};
template<class P_numtype, int N_length>
class SmallVector
{
private:
P_numtype data_[N_length];
public:
// --- length
int length() const
{ return N_length; }
// --- constructors
SmallVector()
{
//meta_Assign<N_length, 0>
//::Assign(data_, P_numtype(), _bz_update<P_numtype, P_numtype>());
}
SmallVector(const SmallVector& from)
{
//meta_Assign<N_length, 0>
// ::Assign(data_, from.data_, _bz_update<T_numtype, T_numtype>());
}
explicit SmallVector(const SmallVectorNoInit&)
{ }
P_numtype& operator ()(int i)
{
return data_;
}
const P_numtype& operator ()(int i) const
{
return data_;
}
};
int main(void)
{
SmallVector<double,4> sv(SmallVectorNoInit());
sv(2) = 1.;
return 0;
}
////////////////////////////////////////////////
Can anyone figure out what's happening ?
Thanks.
g++ gives the next error messages
test.cpp: In function 'int main()':
test.cpp:53: error: invalid conversion from 'int' to 'SmallVectorNoInit
(*)()'
test.cpp:53: error: initializing argument 1 of 'SmallVector<double, 4>
sv(SmallVectorNoInit (*)())'
test.cpp:53: error: no match for 'operator=' in 'sv(SmallVectorNoInit
(*)())() = 1.0e+0'
test.cpp:6: note: candidates are: SmallVector<double, 4>&
SmallVector<double, 4>:perator=(const SmallVector<double, 4>&)
when it compiles the code below:
////////////////////////////////////////////////
struct SmallVectorNoInit {};
template<class P_numtype, int N_length>
class SmallVector
{
private:
P_numtype data_[N_length];
public:
// --- length
int length() const
{ return N_length; }
// --- constructors
SmallVector()
{
//meta_Assign<N_length, 0>
//::Assign(data_, P_numtype(), _bz_update<P_numtype, P_numtype>());
}
SmallVector(const SmallVector& from)
{
//meta_Assign<N_length, 0>
// ::Assign(data_, from.data_, _bz_update<T_numtype, T_numtype>());
}
explicit SmallVector(const SmallVectorNoInit&)
{ }
P_numtype& operator ()(int i)
{
return data_;
}
const P_numtype& operator ()(int i) const
{
return data_;
}
};
int main(void)
{
SmallVector<double,4> sv(SmallVectorNoInit());
sv(2) = 1.;
return 0;
}
////////////////////////////////////////////////
Can anyone figure out what's happening ?
Thanks.