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

Subversion Repositories openrisc

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// { dg-do run }
2
// { dg-options "-std=c++0x" }
3
 
4
// Test user-defined literals.
5
// Test simple operator declaration and definition.
6
 
7
#include 
8
#include 
9
#include 
10
#include 
11
 
12
long double operator"" _v(long double);
13
std::string operator"" _w(const char16_t*, size_t);
14
unsigned operator"" _w(const char*);
15
 
16
std::complex
17
operator"" _i(long double y)
18
{ return std::complex(0.0L, y); }
19
 
20
void
21
test1()
22
{
23
  long double x = operator"" _v(1.2L);
24
  assert(x == 2.2L);
25
 
26
  std::string s = operator"" _w(u"one", 3);
27
  assert(s == "boo");
28
 
29
  unsigned u = operator"" _w("Hello, World!");
30
  assert(u == 13U);
31
 
32
  std::complex i = operator"" _i(2.0);
33
  assert(i == std::complex(0.0, 2.0));
34
}
35
 
36
int
37
main()
38
{
39
  test1();
40
}
41
 
42
long double
43
operator"" _v(long double x)
44
{ return x + 1.0L; }
45
 
46
std::string
47
operator"" _w(const char16_t*, size_t)
48
{ return std::string("boo"); }
49
 
50
unsigned
51
operator"" _w(const char* str)
52
{ return strlen(str); }

powered by: WebSVN 2.1.0

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