fork download
  1. #include <iostream>
  2. #include <array>
  3. #include <type_traits>
  4. #include <utility>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. namespace detail
  10. {
  11.  
  12. template <typename T, std::size_t...Is>
  13. std::array<T, sizeof...(Is)> make_array(const T& value, std::index_sequence<Is...>)
  14. {
  15. return {{(static_cast<void>(Is), value)...}};
  16. }
  17. }
  18.  
  19. template <std::size_t N, typename T>
  20. std::array<T, N> make_array(const T& value)
  21. {
  22. return detail::make_array(value, std::make_index_sequence<N>());
  23. }
  24.  
  25. struct X {
  26. X() {}
  27. X(int) {}
  28. int x;
  29. };
  30.  
  31. struct Y : public X {};
  32.  
  33. struct Q {
  34.  
  35. Q(): m_(make_array<2, X>(0)) {}
  36.  
  37. Q(X x, Y y) : m_{x, y} {}
  38.  
  39. std::array<X, 2> m_;
  40. };
  41.  
  42. struct Z : public std::add_const<X>::type {
  43. };
  44.  
  45. int main() {
  46.  
  47. Z z;
  48. z.x = 0;
  49.  
  50. X x;
  51. Y y;
  52.  
  53. Q q(x, y);
  54.  
  55. return 0;
  56. }
  57.  
  58.  
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty