summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/other/pr50464.C
blob: 8c67213731a40e79b44a5cc68deafc4946480c4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// { dg-do compile { target i?86-*-* x86_64-*-* } }
// { dg-options "-O3 -mxop" }

typedef long unsigned int size_t;
typedef unsigned long ulong_t;
typedef signed long slong_t;

  template<typename _Iterator>
    struct iterator_traits
    {
      typedef typename _Iterator::reference reference;
    };

  template<typename _Tp>
    struct iterator_traits<_Tp*>
    {
      typedef _Tp& reference;
    };

  template<typename _Iterator, typename _Container>
    class __normal_iterator
    {
    protected:
      _Iterator _M_current;
      typedef iterator_traits<_Iterator> __traits_type;

    public:
      typedef typename __traits_type::reference reference;

      explicit
      __normal_iterator(const _Iterator& __i) : _M_current(__i) { }

      reference
      operator*() const
      { return *_M_current; }

      __normal_iterator&
      operator++()
      {
         ++_M_current;
         return *this;
      }

      const _Iterator&
      base() const
      { return _M_current; }
    };

  template<typename _Iterator, typename _Container>
    inline bool
    operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
        const __normal_iterator<_Iterator, _Container>& __rhs)
    { return __lhs.base() != __rhs.base(); }

  template<typename _Tp>
    class allocator
    {
    public:
      typedef _Tp* pointer;
      typedef _Tp value_type;

      template<typename _Tp1>
        struct rebind
        { typedef allocator<_Tp1> other; };

       pointer allocate(size_t __n, const void* = 0)
       {
          return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
       }
    };

  template<typename _Tp, typename _Alloc>
    struct _Vector_base
    {
      typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;

      struct _Vector_impl
      : public _Tp_alloc_type
      {
        typename _Tp_alloc_type::pointer _M_start;
        typename _Tp_alloc_type::pointer _M_finish;
        typename _Tp_alloc_type::pointer _M_end_of_storage;

        _Vector_impl(_Tp_alloc_type const& __a) { }
      };

    public:
      typedef _Alloc allocator_type;

      _Vector_base(size_t __n, const allocator_type& __a)
      : _M_impl(__a)
      {
        this->_M_impl._M_start = this->_M_allocate(__n);
        this->_M_impl._M_finish = this->_M_impl._M_start;
        this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
      }

    public:
      _Vector_impl _M_impl;

      typename _Tp_alloc_type::pointer
      _M_allocate(size_t __n)
      { return __n != 0 ? _M_impl.allocate(__n) : 0; }

    };

  template<typename _Tp, typename _Alloc = allocator<_Tp> >
    class vector : protected _Vector_base<_Tp, _Alloc>
    {
      typedef _Vector_base<_Tp, _Alloc> _Base;
      typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;

    public:
      typedef _Tp value_type;
      typedef typename _Tp_alloc_type::pointer pointer;
      typedef __normal_iterator<pointer, vector> iterator;
      typedef _Alloc allocator_type;

    protected:
      using _Base::_M_allocate;
      using _Base::_M_impl;

    public:

      explicit
      vector(size_t __n, const value_type& __value = value_type(),
      const allocator_type& __a = allocator_type())
      : _Base(__n, __a)
      { _M_fill_initialize(__n, __value); }

      iterator begin()
      { return iterator(this->_M_impl._M_start); }

      iterator end()
      { return iterator(this->_M_impl._M_finish); }

    protected:
      void
      _M_fill_initialize(size_t __n, const value_type& __value)
      {
         this->_M_impl._M_finish = this->_M_impl._M_end_of_storage;
      }
    };

  template<typename _InputIterator, typename _OutputIterator, typename _Tp>
    _OutputIterator
    replace_copy(_InputIterator __first, _InputIterator __last,
   _OutputIterator __result,
   const _Tp& __old_value, const _Tp& __new_value)
    {
      ;
      for (; __first != __last; ++__first, ++__result)
         if (*__first == __old_value)
            *__result = __new_value;
         else
            *__result = *__first;
      return __result;
    }

extern size_t shape_rank;

void createDataspaceIdentifier()
{
  vector< ulong_t > dataspaceDims( shape_rank );
  vector< ulong_t > maxDataspaceDims( shape_rank );

  replace_copy(
    dataspaceDims.begin(), dataspaceDims.end(),
    maxDataspaceDims.begin(), ulong_t( 0 ), ((ulong_t)(slong_t)(-1)) );
}