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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [20_util/] [bind/] [cv_quals.cc] - Blame information for rev 742

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// Copyright (C) 2010 Free Software Foundation, Inc.
2
//
3
// This file is part of the GNU ISO C++ Library.  This library is free
4
// software; you can redistribute it and/or modify it under the
5
// terms of the GNU General Public License as published by the
6
// Free Software Foundation; either version 3, or (at your option)
7
// any later version.
8
 
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
 
14
// You should have received a copy of the GNU General Public License along
15
// with this library; see the file COPYING3.  If not see
16
// <http://www.gnu.org/licenses/>.
17
 
18
// 20.7.11 Function template bind
19
 
20
// { dg-options "-std=gnu++0x" }
21
 
22
#include <functional>
23
#include <testsuite_hooks.h>
24
 
25
// target must be invoked with cv-quals of call wrapper
26
 
27
struct X
28
{
29
  int operator()() { return 0; }
30
  int operator()() const { return 1; }
31
  int operator()() volatile { return 2; }
32
  int operator()() const volatile { return 3; }
33
 
34
  int operator()(int, int, int) { return 0; }
35
  int operator()(int, int, int) const { return 1; }
36
  int operator()(int, int, int) volatile { return 2; }
37
  int operator()(int, int, int) const volatile { return 3; }
38
};
39
 
40
using std::placeholders::_1;
41
using std::placeholders::_2;
42
 
43
void test01()
44
{
45
  bool test __attribute__((unused)) = true;
46
 
47
  auto b0 = std::bind(X());
48
  VERIFY( b0() == 0 );
49
 
50
  const auto b1 = std::bind(X());
51
  VERIFY( b1() == 1 );
52
 
53
  volatile auto b2 = std::bind(X());
54
  VERIFY( b2() == 2 );
55
 
56
  const volatile auto b3 = std::bind(X());
57
  VERIFY( b3() == 3 );
58
}
59
 
60
void test02()
61
{
62
  bool test __attribute__((unused)) = true;
63
 
64
  auto b0 = std::bind<int>(X());
65
  VERIFY( b0() == 0 );
66
 
67
  const auto b1 = std::bind<int>(X());
68
  VERIFY( b1() == 1 );
69
 
70
  volatile auto b2 = std::bind<int>(X());
71
  VERIFY( b2() == 2 );
72
 
73
  const volatile auto b3 = std::bind<int>(X());
74
  VERIFY( b3() == 3 );
75
}
76
 
77
void test03()
78
{
79
  bool test __attribute__((unused)) = true;
80
 
81
  auto b0 = std::bind(X(), 0, _1, _2);
82
  VERIFY( b0(0, 0) == 0 );
83
 
84
  const auto b1 = std::bind(X(), _1, 0, _2);
85
  VERIFY( b1(0, 0) == 1 );
86
 
87
  volatile auto b2 = std::bind(X(), _1, _2, 0);
88
  VERIFY( b2(0, 0) == 2 );
89
 
90
  const volatile auto b3 = std::bind(X(), _1, 0, _2);
91
  VERIFY( b3(0, 0) == 3 );
92
}
93
 
94
void test04()
95
{
96
  bool test __attribute__((unused)) = true;
97
 
98
  auto b0 = std::bind<int>(X(), 0, _1, _2);
99
  VERIFY( b0(0, 0) == 0 );
100
 
101
  const auto b1 = std::bind<int>(X(), _1, 0, _2);
102
  VERIFY( b1(0, 0) == 1 );
103
 
104
  volatile auto b2 = std::bind<int>(X(), _1, _2, 0);
105
  VERIFY( b2(0, 0) == 2 );
106
 
107
  const volatile auto b3 = std::bind<int>(X(), _1, 0, _2);
108
  VERIFY( b3(0, 0) == 3 );
109
}
110
 
111
 
112
int main()
113
{
114
  test01();
115
  test02();
116
  test03();
117
  test04();
118
  return 0;
119
}

powered by: WebSVN 2.1.0

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