1// (C) Copyright Eric Niebler 2005.
2// Use, modification and distribution are subject to the
3// Boost Software License, Version 1.0. (See accompanying file
4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6/*
7 Revision history:
8 25 August 2005 : Initial version.
9*/
10
11#include <vector>
12#include <boost/core/lightweight_test.hpp>
13#include <boost/foreach.hpp>
14
15#ifdef BOOST_FOREACH_NO_CONST_RVALUE_DETECTION
16// ignore error during Microsoft Code Analysis
17#if !defined(_PREFAST_)
18# error Expected failure : const rvalues disallowed
19#endif
20#else
21
22std::vector<int> const get_vector()
23{
24 return std::vector<int>(4, 4);
25}
26
27///////////////////////////////////////////////////////////////////////////////
28// test_main
29//
30int main()
31{
32 int counter = 0;
33
34 BOOST_REVERSE_FOREACH(int i, get_vector())
35 {
36 counter += i;
37 }
38
39 BOOST_TEST(16 == counter);
40
41 return boost::report_errors();
42}
43
44#endif
45

source code of boost/libs/foreach/test/rvalue_const_r.cpp