Skip to content

Instantly share code, notes, and snippets.

@friedmud
Created June 2, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save friedmud/fc12e37974b2d3c5ebdf9a428d235beb to your computer and use it in GitHub Desktop.
Save friedmud/fc12e37974b2d3c5ebdf9a428d235beb to your computer and use it in GitHub Desktop.
#include <iostream>
#include <tuple>
template <class... Ts>
void acceptsTuple(std::tuple<Ts...> values)
{
std::cout << std::get<0>(values) << std::get<1>(values);
}
template <class... Ts>
class AcceptsTuple
{
public:
void acceptsTuple(std::tuple<Ts...> values)
{
std::cout << std::get<0>(values) << std::get<1>(values);
}
};
int main()
{
acceptsTuple<std::string, double>({"stuff", 1.2});
AcceptsTuple<std::string, double> at;
at.acceptsTuple({"stuff", 1.2});
}
@friedmud
Copy link
Author

friedmud commented Jun 2, 2018

Works on Clang/GCC.

On our build boxes it does:

[moosetest@buildq15][~]> icpc -std=c++11 tuple_test.C 
tuple_test.C(22): error: no instance of function template "acceptsTuple" matches the argument list
            argument types are: ({...})
    acceptsTuple<std::string, double>({"stuff", 1.2});
    ^
tuple_test.C(5): note: this candidate was rejected because arguments do not match
  void acceptsTuple(std::tuple<Ts...> values)
       ^

tuple_test.C(26): error: copy-list-initialization cannot use a constructor marked "explicit"
    at.acceptsTuple({"stuff", 1.2});
                    ^

compilation aborted for tuple_test.C (code 2)

On Falcon using icc/2017.1.132-GCC-5.4.0-2.26 it does the same:

gastdr@falcon2:~/projects/falcon> icpc -std=c++11 tuple_test.C
tuple_test.C(22): error: no instance of function template "acceptsTuple" matches the argument list
            argument types are: ({...})
    acceptsTuple<std::string, double>({"stuff", 1.2});
    ^
tuple_test.C(5): note: this candidate was rejected because arguments do not match
  void acceptsTuple(std::tuple<Ts...> values)
       ^

tuple_test.C(26): error: copy-list-initialization cannot use a constructor marked "explicit"
    at.acceptsTuple({"stuff", 1.2});
                    ^

compilation aborted for tuple_test.C (code 2)

However, on Falcon with the very next ICC module (icc/2017.1.132-GCC-6.3.0-2.27) it WORKS:

gastdr@falcon2:~/projects/falcon> module purge
gastdr@falcon2:~/projects/falcon> module load icc/2017.1.132-GCC-6.3.0-2.27
gastdr@falcon2:~/projects/falcon> icpc -std=c++11 tuple_test.C
gastdr@falcon2:~/projects/falcon> 

So it's an intel compiler issue that might just be particular to a version or to a version of GCC it's working with.

@friedmud
Copy link
Author

friedmud commented Jun 2, 2018

Also works fine with the newest intel compiler available on Falcon: icc/2018.1.163-GCC-6.4.0-2.28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment