rjhogan / Adept-2

Combined array and automatic differentiation library in C++
http://www.met.reading.ac.uk/clouds/adept/
Apache License 2.0
163 stars 29 forks source link

Fix implicit conversion warnings #22

Closed yairchu closed 2 years ago

yairchu commented 2 years ago

This fixes the last warnings that my project using Adept has :) When uIndex is int Xcode warns on these:

 implicit conversion loses integer precision: 'std::vector<int>::size_type' (aka 'unsigned long') to 'adept::uIndex' (aka 'int') [-Wshorten-64-to-32]
    uIndex n_dependents() const { return dependent_index_.size(); }
rjhogan commented 2 years ago

I'd prefer static_cast() than a C-style cast please. Note that the cause of this is the "mistake" (according to Bjarne Stroustrup no less) that the C++ standard library uses an unsigned type to represent the size of a container. Google and many other house styles recommend signed types for the size of a container, which Adept uses (despite the legacy "uIndex" name).

yairchu commented 2 years ago

I'd prefer static_cast() than a C-style cast please.

Done!