[C++-sig] int vs. char
Neal Becker
ndbecker2 at gmail.com
Tue Oct 17 17:01:59 CEST 2006
In wrapping ublas::vector class, I enountered the following tiny problem.
Here is one constructor:
template<typename T>
inline vector<T>* vector_with_init (int size, object const& init) {
T ival = extract<T> (init);
return new vector<T> (size, ival);
}
In the case of vector<char> (T==char), then this python code fails:
u = vector_char (K, 0)
TypeError: No registered converter was able to produce a C++ rvalue of type
char from this Python object of type int
Of course, this will work:
u = vector_char (K, char(0))
But I wonder if there is a better solution?
More information about the Cplusplus-sig
mailing list