I just found that C ++ does not give any warnings about casting from pair<double, int> to pair<int, int> , which is a bit surprising. Here is my test_pair.cpp program:
#include <vector> #include <utility> using namespace std; int main() { std::vector<pair<int, int> > v; pair<double, int> p = make_pair(3.8, 3); v.push_back(p); }
I will compile it with g++ test_type.cpp -Wall -Wconversion , but still no warnings are generated. I am using g ++ v4.6.1. Has anyone figured out how to get g ++ to generate a warning for this, or simply can't be done?
c ++ g ++
chtlp
source share