The following code fails to compile with icpc version 16.0.2 20160204 on OS X 10.11.4, but compiles fine with Clang and GCC:
#include <iostream> #include <map> int main( int argc, char** argv ) { std::map<int,int> test_map{ {1,2}, {3,4}, {5,6} }; auto voxel_iterator{ test_map.find( 5 ) }; //auto voxel_iterator = test_map.find( 5 ); std::cout << voxel_iterator->first << " -> "<< voxel_iterator->second << std::endl; }
I receive the following error when compiling the code with 'icpc -std=c++11 main.cpp':
main.cpp(8): error: expression must have pointer type std::cout << voxel_iterator->first << " -> "<< voxel_iterator->second << std::endl; ^ main.cpp(8): error: expression must have pointer type std::cout << voxel_iterator->first << " -> "<< voxel_iterator->second << std::endl;
It seems that icpc is not deducing the return type of find as an iterator when uniform initialization syntax is used. Replacing uniform initialization with '=' (see the commented line) results in the correct type deduction. Is this the expected behavior with uniform initialization?