matplotlib/matplotlib — pull request #1434 by mgiuca-google (2012-10-29 22:51:40+00:00)
Title: C++11 narrowing conversions

Just a couple of small fixes to allow Matplotlib to compile with -std=c++11. The problem is that C++11 does not allow implicit narrowing conversions (in this case, a cast from size_t, which is unsigned, to npy_intp, which is signed) in an initialiser list.

I was getting errors compiling these files with clang and -std=c++11:

lib/matplotlib/tri/_tri.cpp:280:25: error: non-constant-expression cannot be narrowed from type 'size_type' (aka 'unsigned long') to 'npy_intp' (aka 'long') in initializer list
lib/matplotlib/tri/_tri.cpp:574:29: error: non-constant-expression cannot be narrowed from type 'size_type' (aka 'unsigned long') to 'npy_intp' (aka 'long') in initializer list
src/_path.cpp:1356:33: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'npy_intp' (aka 'long') in initializer list

This patch fixes those errors. Note that GCC 4.6 with -std=c++0x [does not catch this error](http://stackoverflow.com/a/8251081/368821), even though it violates the new specification. I don't know if GCC 4.7 has fixed this, but in any case, it is good to be future-proof.