fork download
  1.  
  2. #include <type_traits>
  3. #include <string>
  4. #include <sstream>
  5. #include <map>
  6. #include <functional>
  7. #include <stdexcept>
  8. #include <memory>
  9. #include <set>
  10. #include <algorithm>
  11. #include <fstream>
  12. #include <algorithm>
  13. #include <iostream>
  14. #include <array>
  15. #include <iterator>
  16. #include <clocale>
  17. #include <iostream>
  18. #include <ostream>
  19.  
  20.  
  21. template <typename T, typename V>
  22. decltype(new T(*((V*)0))) create_(V param, int) {
  23. std::cout << "T(1)\n";
  24. return new T(param);
  25. }
  26.  
  27. template <typename T, typename V>
  28. T * create_(V...) {
  29. std::cout << "T\n";
  30. return new T();
  31. }
  32.  
  33. template <typename T, typename V>
  34. T* create(V param)
  35. {
  36. return create_<T>(param, 7);
  37. }
  38.  
  39. struct S{
  40. S(char c){
  41. std::cout << "char: " << c <<"\n";
  42. }
  43. S(){}
  44. };
  45.  
  46. struct G
  47. {
  48.  
  49. };
  50.  
  51. int main()
  52. {
  53. create<S>('d');
  54. create<G>('b');
  55. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'decltype (new T) create_(V, int) [with T = S, V = char, decltype (new T) = S*]':
prog.cpp:36:31:   instantiated from 'T* create(V) [with T = S, V = char]'
prog.cpp:53:18:   instantiated from here
prog.cpp:22:27: sorry, unimplemented: mangling new-expression
stdout
Standard output is empty