cxx_generalized_initializers.cpp 772 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #if defined(_MSC_VER) && _MSC_VER == 1800 && _MSC_FULL_VER < 180030723
  2. #error "VS 2013 safely supports this only with Update 3 or greater"
  3. #endif
  4. // Dummy implementation. Test only the compiler feature.
  5. namespace std {
  6. typedef decltype(sizeof(int)) size_t;
  7. template <class _E>
  8. class initializer_list
  9. {
  10. const _E* __begin_;
  11. size_t __size_;
  12. #ifdef __INTEL_COMPILER
  13. // The Intel compiler internally asserts the constructor overloads, so
  14. // reproduce the constructor used in its <initializer_list> header.
  15. initializer_list(const _E*, size_t) {}
  16. #else
  17. public:
  18. template <typename T1, typename T2>
  19. initializer_list(T1, T2)
  20. {
  21. }
  22. #endif
  23. };
  24. }
  25. template <typename T>
  26. struct A
  27. {
  28. A(std::initializer_list<T>) {}
  29. };
  30. void someFunc()
  31. {
  32. A<int> as = { 1, 2, 3, 4 };
  33. }