louisdx / cxx-prettyprint

A header-only library for C++(0x) that allows automagic pretty-printing of any container.
http://louisdx.github.com/cxx-prettyprint/
Boost Software License 1.0
557 stars 73 forks source link

Intel Compiler Error: invalid partial specialization #31

Open fsimonis opened 4 years ago

fsimonis commented 4 years ago

The following code fails to compile with the Intel Compiler icc (ICC) 2021.1 Beta 20200827: gcc and clang compile this code without problems.

// ex.cpp
#include<iostream>
#include<vector>
#include<utility>

#include "prettyprint.hpp"

int main() {
  std::vector<std::pair<int, std::vector<int>>> v;
  std::cout << v << std::endl;
  return 1;
}

I ran the code using a docker container based on the official intel image intel/oneapi-hpckit. The following is the slightly cleaned-up output of icc including the setup of the docker container.

> ls
ex.cpp
prettyprint.hpp

> docker run --rm -it -v$(pwd):/src:ro intel/oneapi-hpckit

# icc -I /src/ /src/ex.cpp 
/src/prettyprint.hpp(152): error: invalid partial specialization -- class "pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters>::printer<std::pair<int, std::vector<int, std::allocator<int>>>> [with T=std::vector<int, std::allocator<int>>, TChar=char, TCharTraits=std::char_traits<char>, TDelimiters=pretty_print::delimiters<std::vector<int, std::allocator<int>>, char>]" is already fully specialized
  struct print_container_helper<T, TChar, TCharTraits, TDelimiters>::printer<std::pair<T1, T2>> {
                                                                     ^
          detected during:
            instantiation of class "pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters> [with T=std::vector<int, std::allocator<int>>, TChar=char, TCharTraits=std::char_traits<char>, TDelimiters=pretty_print::delimiters<std::vector<int, std::allocator<int>>, char>]" at line 475
            instantiation of "std::enable_if<pretty_print::is_container<T>::value, std::basic_ostream<TChar, TCharTraits> &>::type std::operator<<(std::basic_ostream<TChar, TCharTraits> &, const T &) [with T=std::vector<int, std::allocator<int>>, TChar=char, TCharTraits=std::char_traits<char>]" at line 160

            instantiation of "void pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters>::printer<std::pair<T1, T2>>::print_body(const std::pair<T1, T2> &, pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters>::printer<std::pair<T1, T2>>::ostream_type &) [with T=std::pair<int, std::vector<int, std::allocator<int>>>, TChar=char, TCharTraits=std::char_traits<char>, TDelimiters=pretty_print::delimiters<std::pair<int, std::vector<int, std::allocator<int>>>, char>, T1=int, T2=std::vector<int, std::allocator<int>>]" at line 138
            instantiation of "void pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters>::operator()(pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters>::ostream_type &) const [with T=std::pair<int, std::vector<int, std::allocator<int>>>, TChar=char, TCharTraits=std::char_traits<char>, TDelimiters=pretty_print::delimiters<std::pair<int, std::vector<int, std::allocator<int>>>, char>]" at line 211
            instantiation of "std::basic_ostream<TChar, TCharTraits> &pretty_print::operator<<(std::basic_ostream<TChar, TCharTraits> &, const pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters> &) [with T=std::pair<int, std::vector<int, std::allocator<int>>>, TChar=char, TCharTraits=std::char_traits<char>, TDelimiters=pretty_print::delimiters<std::pair<int, std::vector<int, std::allocator<int>>>, char>]" at line 475
            instantiation of "std::enable_if<pretty_print::is_container<T>::value, std::basic_ostream<TChar, TCharTraits> &>::type std::operator<<(std::basic_ostream<TChar, TCharTraits> &, const T &) [with T=std::pair<int, std::vector<int, std::allocator<int>>>, TChar=char, TCharTraits=std::char_traits<char>]" at line 116

            instantiation of "void pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters>::printer<U>::print_body(const U &, pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters>::ostream_type &) [with T=std::vector<std::pair<int, std::vector<int, std::allocator<int>>>, std::allocator<std::pair<int, std::vector<int, std::allocator<int>>>>>, TChar=char, TCharTraits=std::char_traits<char>, TDelimiters=pretty_print::delimiters<std::vector<std::pair<int, std::vector<int, std::allocator<int>>>, std::allocator<std::pair<int, std::vector<int, std::allocator<int>>>>>, char>, U=std::vector<std::pair<int, std::vector<int, std::allocator<int>>>, std::allocator<std::pair<int, std::vector<int, std::allocator<int>>>>>]" at line 138
            instantiation of "void pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters>::operator()(pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters>::ostream_type &) const [with T=std::vector<std::pair<int, std::vector<int, std::allocator<int>>>, std::allocator<std::pair<int, std::vector<int, std::allocator<int>>>>>, TChar=char, TCharTraits=std::char_traits<char>, TDelimiters=pretty_print::delimiters<std::vector<std::pair<int, std::vector<int, std::allocator<int>>>, std::allocator<std::pair<int, std::vector<int, std::allocator<int>>>>>, char>]" at line 211
            instantiation of "std::basic_ostream<TChar, TCharTraits> &pretty_print::operator<<(std::basic_ostream<TChar, TCharTraits> &, const pretty_print::print_container_helper<T, TChar, TCharTraits, TDelimiters> &) [with T=std::vector<std::pair<int, std::vector<int, std::allocator<int>>>, std::allocator<std::pair<int, std::vector<int, std::allocator<int>>>>>, TChar=char, TCharTraits=std::char_traits<char>, TDelimiters=pretty_print::delimiters<std::vector<std::pair<int, std::vector<int, std::allocator<int>>>, std::allocator<std::pair<int, std::vector<int, std::allocator<int>>>>>, char>]" at line 475
            instantiation of "std::enable_if<pretty_print::is_container<T>::value, std::basic_ostream<TChar, TCharTraits> &>::type std::operator<<(std::basic_ostream<TChar, TCharTraits> &, const T &) [with T=std::vector<std::pair<int, std::vector<int, std::allocator<int>>>, std::allocator<std::pair<int, std::vector<int, std::allocator<int>>>>>, TChar=char, TCharTraits=std::char_traits<char>]" at line 9 of "/src/ex.cpp"

compilation aborted for /src/ex.cpp (code 2)