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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [template_deduction.C] - Blame information for rev 301

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

Line No. Rev Author Line
1 301 jeremybenn
// I, Howard Hinnant, hereby place this code in the public domain.
2
 
3
// Test the "Augmented" template argument deduction when binding an lvalue to an rvalue reference.
4
 
5
// { dg-do compile }
6
// { dg-options "-std=c++0x" }
7
 
8
template  struct sa;
9
template <> struct sa {};
10
 
11
template 
12
struct integral_constant
13
{
14
        static const T                  value = v;
15
        typedef T                       value_type;
16
        typedef integral_constant type;
17
};
18
 
19
typedef integral_constant  true_type;
20
typedef integral_constant false_type;
21
 
22
template  struct is_lvalue_reference     : public integral_constant {};
23
template  struct is_lvalue_reference : public integral_constant {};
24
 
25
template  struct is_rvalue_reference      : public integral_constant {};
26
template  struct is_rvalue_reference : public integral_constant {};
27
 
28
template 
29
void
30
test1(T&&)
31
{
32
    sa::value == is_lvalue_ref> t1;
33
    sa::value == is_rvalue_ref> t2;
34
}
35
 
36
template 
37
void
38
test2(const T&&)                // { dg-error "argument" }
39
{
40
    sa::value == is_lvalue_ref> t1;
41
    sa::value == is_rvalue_ref> t2;
42
}
43
 
44
template 
45
void
46
test3(T*&&)
47
{
48
    sa::value == is_lvalue_ref> t1;
49
    sa::value == is_rvalue_ref> t2;
50
}
51
 
52
struct A {};
53
 
54
A a;
55
 
56
A source() {return A();}
57
A* sourcep() {return 0;}
58
 
59
int main()
60
{
61
    test1(a);
62
    test1(source());
63
    test2(a);   // { dg-error "lvalue" }
64
    test2(source());
65
    test3(&a);
66
    test3(sourcep());
67
    return 0;
68
}

powered by: WebSVN 2.1.0

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