is_a<function>: C++11 compiler issue?
Dear All, I am trying to compile the following code: #include <ginac/ginac.h> using namespace GiNaC; using namespace std; int main () { symbol x("x"); ex a=exp(x); cout << is_a<symbol>(x) << endl; cout << is_a<function>(a) << endl; } If a compiler option -std=gnu++11 is used, I got errors like this: test-g.cpp:9:26: error: no matching function for call to 'is_a(GiNaC::ex&)' cout << is_a<function>(a) << endl; (see the full log at the end of my message). Compiler complains about is_a<symbol> but is happy with is_a<function>(a). The code can be compiled and run well if -std=gnu++11 is omitted. Any suggestions? Best wishes, Vladimir -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/ ===================================================================== test-g.cpp: In function 'int main()': test-g.cpp:9:10: error: parse error in template argument list cout << is_a<function>(a) << endl; ^ test-g.cpp:9:26: error: no matching function for call to 'is_a(GiNaC::ex&)' cout << is_a<function>(a) << endl; ^ In file included from /usr/include/ginac/registrar.h:27:0, from /usr/include/ginac/basic.h:29, from /usr/include/ginac/ginac.h:28, from test-g.cpp:1: /usr/include/ginac/print.h:181:13: note: candidate: template<class T> bool GiNaC::is_a(const GiNaC::print_context&) inline bool is_a(const print_context & obj) ^ /usr/include/ginac/print.h:181:13: note: template argument deduction/substitution failed: test-g.cpp:9:26: error: template argument 1 is invalid cout << is_a<function>(a) << endl; ^ In file included from /usr/include/ginac/ginac.h:28:0, from test-g.cpp:1: /usr/include/ginac/basic.h:311:13: note: candidate: template<class T> bool GiNaC::is_a(const GiNaC::basic&) inline bool is_a(const basic &obj) ^ /usr/include/ginac/basic.h:311:13: note: template argument deduction/substitution failed: test-g.cpp:9:26: error: template argument 1 is invalid cout << is_a<function>(a) << endl; ^ In file included from /usr/include/ginac/ginac.h:30:0, from test-g.cpp:1: /usr/include/ginac/ex.h:930:13: note: candidate: template<class T> bool GiNaC::is_a(const GiNaC::ex&) inline bool is_a(const ex &obj) ^ /usr/include/ginac/ex.h:930:13: note: template argument deduction/substitution failed: test-g.cpp:9:26: error: template argument 1 is invalid cout << is_a<function>(a) << endl; ^
Hi Vladimir, On 07/08/2016 10:28 AM, Vladimir V. Kisil wrote:
I am trying to compile the following code:
#include <ginac/ginac.h> using namespace GiNaC; using namespace std; int main () { symbol x("x"); ex a=exp(x); cout << is_a<symbol>(x) << endl; cout << is_a<function>(a) << endl; }
If a compiler option -std=gnu++11 is used, I got errors like this:
test-g.cpp:9:26: error: no matching function for call to 'is_a(GiNaC::ex&)' cout << is_a<function>(a) << endl;
(see the full log at the end of my message). Compiler complains about is_a<symbol> but is happy with is_a<function>(a).
The code can be compiled and run well if -std=gnu++11 is omitted.
Any suggestions?
Sigh. Your using directives cause a name clash about std::function (new since C++11) and good old class GiNaC::function: <http://en.cppreference.com/w/cpp/utility/functional/function>. I recommend that you disambiguate manually. All my best, -richy. -- Richard B. Kreckel <http://in.terlu.de/~kreckel/>
On Sat, 9 Jul 2016 22:21:16 +0200, "Richard B. Kreckel" <kreckel@in.terlu.de> said: RBK> Sigh. Your using directives cause a name clash about RBK> std::function (new since C++11) and good old class RBK> GiNaC::function:
Yes, now I recollect, that you have already explained this in some patches. Not to forget it for a while, I made a patch for the tutorial. -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/
participants (2)
-
Richard B. Kreckel
-
Vladimir V. Kisil