Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Using alias templates as template template parameters.

Raffael_C_
Beginner
292 Views

Hello,

I'm currently working with Intel compiler under Windows (Version 13.1.3) and try to use alias templates as template template parameters. Essentially I would like to compile something like this:

[cpp]

#include <iostream>

using namespace std;

template<class A, class B>
struct Temp {
int foo() {
return 42;
}
};

template<class A>
using c_t = Temp<A,int>;

template<template<class> class TYPE>
struct Temp2 {
TYPE<int> a;
void foo() {
cout << a.foo() << endl;
}
};

int main()
{
Temp2<c_t> a;
a.foo();

return 0;
}

[/cpp]

This code compiles fine e.g. with GNU gcc 4.7.1. but the Intel compiler complains that the alias template c_t is not compatible with the template tempalte parameter TYPE.  Is gcc here not restrictive enough or is it an actual bug in icl? A post on stackoverflow (http://stackoverflow.com/questions/7319567/can-i-use-template-aliases-as-template-template-parameters) seems to suggest the latter...

(I used the following command line arguments to compile: /Qstd=c++11 /Qlocation )

Best Regards,

Raffael

0 Kudos
4 Replies
Melanie_B_Intel
Employee
292 Views

I tried your test case on Windows with a later version of the compiler (13.1.*) and it compiles without errors, printing 42. Could you re-try after updating with the latest available?

0 Kudos
SergeyKostrov
Valued Contributor II
292 Views
>>...I used the following command line arguments to compile: /Qstd=c++11 /Qlocation... Why do you need /Qlocation option? This is what command line help shows for that option: ... /Qlocation, [ tool ], [ dir ] set [ dir ] as the location of tool specified by [ tool ] ...
0 Kudos
SergeyKostrov
Valued Contributor II
292 Views
Just for comparison these are results for version 12 of Intel C++ compiler: [ Compilation Output ] ..\Tests>icl.exe /Qstd=c++0x /Qlocation Test26.cpp Intel(R) C++ Compiler XE for applications running on IA-32, Version 12.1.7.371 Build 20120928 Copyright (C) 1985-2012 Intel Corporation. All rights reserved. icl: command line warning #10006: ignoring unknown option '/Qlocation' Test26.cpp Microsoft (R) Incremental Linker Version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved. -out:Test26.exe Test26.obj [ Test Output ] ..\Tests>Test26.exe 42 ..\Tests>
0 Kudos
Raffael_C_
Beginner
292 Views

Hi Melanie and Sergey,

First of all thanks a lot for debugging the test case! The test case that I posted seems to compile indeed :)

I found out last week that I made a stupid mistake while compiling the test case with the Intel Compiler: In reality my problem is way more complex and spans over 4 different (Traits-) classes, so I've tried to reduce the problem to the above test case but I must have made an error while compiling it in order to get the error message, arrgh. I guess I was a bit confused because my real problem has indeed this error message.

I tried today for four hours to reduce my problem to a form which I could post here but it's almost impossible. So I've decided to circumvent the problem with another helper class that substitutes the alias template.

Thanks again for your efforts!

Raffael

0 Kudos
Reply