The following code will not compile with icpc 15.0.2:
#include <algorithm> #include <array> #include <numeric> template<typename T> T const & (*maxer) (T const &, T const &) = std::max<T>; int main(void) { std::array<float, 8> data; std::iota(data.begin(), data.end(), 0.0f); if (std::accumulate(data.begin(), data.end(), 0.0f, maxer<float>) == 7.0f) { return 0; } else { return 1; } }
Here is the output:
$ icpc -std=c++14 -Wall -Wextra max.cc max.cc(6): error: "maxer" is not a function or static data member T const & (*maxer) (T const &, T const &) = std::max<T>; ^ max.cc(11): error: identifier "maxer" is undefined if (std::accumulate(data.begin(), data.end(), 0.0f, maxer<float>) == 7.0f) { ^ max.cc(11): error: type name is not allowed if (std::accumulate(data.begin(), data.end(), 0.0f, maxer<float>) == 7.0f) { ^ max.cc(11): error: expected an expression if (std::accumulate(data.begin(), data.end(), 0.0f, maxer<float>) == 7.0f) { ^ compilation aborted for max.cc (code 2)
This code compiles successfully under clang++ and g++. As far as I can tell it is completely standards complaint. I suspect this is just a bug. I can work around it in the meantime by removing the template and hard-coding a type.