Ticket #1572: bll_deref.cpp

File bll_deref.cpp, 1.0 KB (added by Shunsuke Sogame <pstade.mb@…>, 15 years ago)

failed example.

Line 
1
2#include <boost/lambda/lambda.hpp>
3#include <boost/lambda/core.hpp>
4#include <string>
5#include <boost/shared_ptr.hpp>
6#include <boost/detail/lightweight_test.hpp>
7
8
9int main()
10{
11 namespace bll = boost::lambda;
12 {
13 int *x = new int(0);
14
15 *x = 1;
16 BOOST_TEST(*x == 1);
17
18 (*bll::_1)(x) = 2; // ok.
19 BOOST_TEST(*x == 2);
20 }
21 {
22 std::string s("0");
23 std::string::iterator x = s.begin();
24
25 *x = '1';
26 BOOST_TEST(*x == '1');
27
28 (*bll::_1)(x) = '2'; // ok.
29 BOOST_TEST(*x == '2');
30 }
31 {
32 std::string s("0");
33 std::string::iterator const x = s.begin();
34
35 *x = '1';
36 BOOST_TEST(*x == '1');
37
38 (*bll::_1)(x) = '2'; // doesn't compile.
39 BOOST_TEST(*x == '2');
40 }
41 {
42 boost::shared_ptr<int> const x(new int(0));
43
44 *x = 1;
45 BOOST_TEST(*x == 1);
46
47 (*bll::_1)(x) = 2; // doens't compile.
48 BOOST_TEST(*x == 2);
49 }
50
51 return boost::report_errors();
52}