OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [explicit1.C] - Blame information for rev 693

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// Test for explicit conversion ops from N2437.
2
// { dg-options "-std=c++0x" }
3
 
4
class U; class V;
5
class T
6
{
7
public:
8
  T( U const & );
9
  //implicit converting ctor
10
  explicit T( V const & );
11
  // explicit ctor
12
};
13
class U
14
{
15
};
16
class V
17
{
18
};
19
class W
20
{
21
public:
22
  operator T() const;
23
};
24
class X
25
{
26
public:
27
  explicit operator T() const; // theoretical
28
};
29
int main()
30
{
31
  U u; V v; W w; X x;
32
  // Direct initialization:
33
  T t1( u );
34
  T t2( v );
35
  T t3( w );
36
  T t4( x );
37
  // Copy initialization:
38
  T t5 = u;
39
  T t6 = v;                     // { dg-error "" }
40
  T t7 = w;
41
  T t8 = x;                     // { dg-error "" }
42
  // Cast notation:
43
  T t9 = (T) u;
44
  T t10 = (T) v;
45
  T t11 = (T) w;
46
  T t12 = (T) x;
47
  // Static cast:
48
  T t13 = static_cast( u );
49
  T t14 = static_cast( v );
50
  T t15 = static_cast( w );
51
  T t16 = static_cast( x );
52
  // Function-style cast:
53
  T t17 = T( u );
54
  T t18 = T( v );
55
  T t19 = T( w );
56
  T t20 = T( x );
57
  return 0;
58
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.