URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [range-for6.C] - Rev 774
Go to most recent revision | Compare with Previous | Blame | View Log
// Test for range-based for loop
// Test the loop with an initializer_list
// { dg-do run }
// { dg-options "-std=c++0x" }
#include <initializer_list>
extern "C" void abort();
template<typename T> T foo()
{
T sum = 0;
for (T x : {T(1),T(2),T(3),T(4)})
sum += x;
if (sum != T(10))
abort();
}
int main()
{
int sum = 0;
for (int x : {1,2,3,4})
sum += x;
if (sum != 10)
abort();
foo<int>();
}
Go to most recent revision | Compare with Previous | Blame | View Log