Ticket #2014: test.cpp

File test.cpp, 557 bytes (added by martin.apel@…, 14 years ago)

Test program demonstrating the issue

Line 
1#include <string>
2#include <sstream>
3#include <iostream>
4#include <boost/spirit/core.hpp>
5#include <boost/spirit/actor.hpp>
6
7int main(void)
8{
9 using namespace std;
10 using namespace boost::spirit;
11
12 double d;
13 string s("0.6");
14 parse(s.begin(), s.end(), real_p[assign_a(d)]);
15 cout.setf(std::ios::fixed|std::ios::left);
16 cout.precision(20);
17 cout << "Parsing with Spirit gives: " << d << endl;
18
19 stringstream stream(s);
20 double std_result;
21 stream >> std_result;
22 std::cout << "Parsing with iostream gives: " << std_result << endl;
23}