aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/torture/pr44972.C
blob: e409148da1c32c0df89d8291b1088fd847a8a385 (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
/* { dg-do compile } */

#include<cassert>
#include<new>
#include<utility>

namespace boost {

template<class T>
class optional;

class aligned_storage
{
	char data[ 1000 ];
  public:
    void const* address() const { return &data[0]; }
    void      * address()       { return &data[0]; }
} ;


template<class T>
class optional_base
{
  protected :
    optional_base(){}
    optional_base ( T const& val )
    {
      construct(val);
    }

    template<class U>
    void assign ( optional<U> const& rhs )
    {
      if (!is_initialized())
        if ( rhs.is_initialized() )
          construct(T());
    }

  public :

    bool is_initialized() const { return m_initialized ; }

  protected :

    void construct ( T const& val )
     {
       new (m_storage.address()) T(val) ;
     }

    T const* get_ptr_impl() const
    { return static_cast<T const*>(m_storage.address()); }

  private :

    bool m_initialized ;
    aligned_storage  m_storage ;
} ;


template<class T>
class optional : public optional_base<T>
{
    typedef optional_base<T> base ;

  public :

    optional() : base() {}
    optional ( T const& val ) : base(val) {}
    optional& operator= ( optional const& rhs )
      {
        this->assign( rhs ) ;
        return *this ;
      }

    T const& get() const ;

    T const* operator->() const { assert(this->is_initialized()) ; return this->get_ptr_impl() ; }

} ;


} // namespace boost


namespace std
{

  template<typename _Tp, std::size_t _Nm>
    struct array
    {
      typedef _Tp 	    			      value_type;
      typedef const value_type*			      const_iterator;

      value_type _M_instance[_Nm];

    };
}


class NT
{
  double _inf, _sup;
};


template < typename T > inline
std::array<T, 1>
make_array(const T& b1)
{
  std::array<T, 1> a = { { b1 } };
  return a;
}

class V
{
  typedef std::array<NT, 1>               Base;
  Base base;

public:
  V() {}
  V(const NT &x)
    : base(make_array(x)) {}

};

using boost::optional ;

optional< std::pair< NT, NT > >
  linsolve_pointC2() ;

optional< V > construct_normal_offset_lines_isecC2 ( )
{
  optional< std::pair<NT,NT> > ip;

  ip = linsolve_pointC2();

  V a(ip->first) ;
  return a;
}