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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [constexpr-array-ptr5.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-options -std=c++0x }
2
 
3
template
4
constexpr T do_last(T* x, int n) {
5
 return x[n - 1]; //
6
}
7
 
8
template
9
constexpr T last(T (&x)[N]) {
10
 return do_last(x, N);
11
}
12
 
13
constexpr bool is_negative(int x) { return x < 0; }
14
 
15
template
16
struct IsNegative {
17
  constexpr bool operator()(const T& x) {
18
    return x < T(0);
19
  }
20
};
21
 
22
template
23
constexpr bool has_neg(T (&x)[N], Pred p) {
24
  return p(last(x)); // Line 22
25
}
26
 
27
constexpr int a[] = {1, -2};
28
 
29
constexpr auto answer1 = has_neg(a, IsNegative{}); // Line 27
30
constexpr auto answer2 = has_neg(a, is_negative);
31
 
32
static_assert(answer2 == answer1, "Error");

powered by: WebSVN 2.1.0

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