2014-10-05 2:34 GMT+04:00 Niall Douglas <s_sourceforge@nedprod.com>:
On 4 Oct 2014 at 14:42, Mathias Gaunard wrote:
On 04/10/2014 13:24, Niall Douglas wrote:
Andrey, please list here three C++ compilers which had at least one version release in the past five years which doesn't provide a magic macro expanding out to the mangling of the enclosing function.
What about MinGW?
I just ran the following program on MinGW:
#include <iostream> #include <typeinfo>
template<class T> void doprint(T a) { std::cout << __func__ << std::endl; std::cout << __FUNCTION__ << std::endl; std::cout << __PRETTY_FUNCTION__ << std::endl; struct $$$ { }; std::cout << typeid($$$).name() << std::endl; } template<class T> struct doprint$$$___$$$ { };
int main(void) { doprint(1); std::cout << typeid(doprint$$$___$$$<int>).name() << std::endl; return 0; }
It prints:
doprint doprint void doprint(T) [with T = int] Z7doprintIiEvT_E3$$$ 16doprint$$$___$$$IiE
I've enchanted the previous example and the results are not very good: #include <typeinfo> #include <iostream> #include <boost/variant.hpp> namespace foo { namespace adl_barrier { BOOST_SYMBOL_EXPORT boost::variant<int, short> export_me_function(boost::variant<int, short>, boost::variant<int, short>) { return 0; } BOOST_SYMBOL_EXPORT boost::variant<int, short> export_me_variable; } // namespace adl_barrier using adl_barrier::export_me_function; using adl_barrier::export_me_variable; } template <boost::variant<int, short>& var> struct printer {}; template <boost::variant<int, short>(&var)(boost::variant<int, short>, boost::variant<int, short>)> struct printer2 {}; int main() { std:: cout << typeid(printer2<foo::export_me_function>).name() << std::endl; std:: cout << typeid(printer<foo::export_me_variable>).name() << std::endl; } Code from above will output: Linux: 8printer2ILZN3foo11adl_barrier18export_me_functionEN5boost7variantIisNS2_6detail7variant5void_ES6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_EES7_EE 7printerILZN3foo11adl_barrier18export_me_variableEEE Windows: .?AU?$printer2@$1?export_me_function@adl_barrier@foo@ @YA?AV?$variant@HFUvoid_@0detail@boost@@U1023@U1023@U1023@U1023@U1023@U1023 @U1023@U1023@U1023@U1023@U10 23@U1023@U1023@U1023@U1023@U1023@U1023@@boost@@V45@0@Z@@ .?AU?$printer@$E?export_me_variable@adl_barrier@foo@@3V?$variant@HFUvoid_ @0detail@boost@@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023 @U1023@U 1023@U1023@U1023@U1023@U1023@U1023@@boost@@A@@ While we still need the following: Linux: _ZN3foo11adl_barrier18export_me_functionEN5boost7variantIisNS1_6detail7variant5void_ES5_S5_S5_S5_S5_S5_S5_S5_S5_S5_S5_S5_S5_S5_S5_S5_S5_EES6_ _ZN3foo11adl_barrier18export_me_variableE Windows: ?export_me_function@adl_barrier@foo@@YA?AV?$variant@HFUvoid_@0detail@boost @@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023 @U1023@U1 023@U1023@U1023@U1023@@boost@@V34@0@Z ?export_me_variable@adl_barrier@foo@@3V?$variant@HFUvoid_@0detail@boost @@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023@U1023 @U1023@U1023 @U1023@U1023@U1023@@boost@@A Looks like such method is not very good, function definition has changed (Linux:5 was transformed into 6, 1 was tranformed into 2; Windows: V34 changed into V45)... I'm afraid that there'll be more surprises -- Best regards, Antony Polukhin