This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/67605] New: Compilation errors creating std::pair using templated arguments
- From: "kplatz at utdallas dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Sep 2015 20:45:45 +0000
- Subject: [Bug c++/67605] New: Compilation errors creating std::pair using templated arguments
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67605
Bug ID: 67605
Summary: Compilation errors creating std::pair using templated
arguments
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kplatz at utdallas dot edu
Target Milestone: ---
The following code compiles correctly on the GCC-4.8 series, but errors out on
GCC-4.9 and 5.X:
#include <algorithm>
#include <utility>
template<int K> class List;
template<int K>
class List {
template<int KK>
class Node {
public:
static const int SPLIT;
Node<KK>* next; // Next pointer
int keys[KK]; // Set of key/data pairs.
Node() : next(nullptr) {
std::fill(keys, keys + KK, 0);
}
};
public:
std::pair<Node<K>*, Node<K>*> scan();
};
template <int K>
std::pair<List<K>::Node<K>*, List<K>::Node<K>*> List<K>::scan( ) {
return std::make_pair( nullptr, nullptr );
}
int main() {
List<1> foo;
auto bar = foo.scan();
}
The errors reported are:
[ken@sager ~]$ g++520 --std=c++11 urllist1.cpp
urllist1.cpp:32:26: error: wrong number of template arguments (1, should be 2)
std::pair<List<K>::Node<K>*, List<K>::Node<K>*> List<K>::scan( ) {
^
In file included from /usr/local/include/c++/5.2.0/utility:70:0,
from /usr/local/include/c++/5.2.0/algorithm:60,
from urllist1.cpp:8:
/usr/local/include/c++/5.2.0/bits/stl_pair.h:96:12: note: provided for
âtemplate<class _T1, class _T2> struct std::pairâ
struct pair
^
urllist1.cpp:32:28: error: expected unqualified-id before â,â token
std::pair<List<K>::Node<K>*, List<K>::Node<K>*> List<K>::scan( ) {