$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Joel de Guzman (joel_at_[hidden])
Date: 2008-06-16 12:20:29
Martin Apel wrote:
> the mentioned FAQ entry is about an assertion triggered at runtime, but 
> I don't even come that far, because the problem happens
> at compile time. 
Ok...
> While trying to generate a small example, I found out, 
> what is causing the problem:
> I marked the grammar class using the closure with __declspec(dllexport), 
> which causes MSVC to instantiate all members of a template,
> even if they are never needed. It seems that otherwise the "context" 
> member function is never instantiated.
> If you remove the __declspec(dllexport), everything compiles. I still 
> think, that the code is wrong, because it returns a pointer, where it
> should return a reference. I have attached a small example, which 
> triggers the problem.
No it is not. You can return a reference to a pointer. Example:
char const*& foo()
{
     static char const* s = "hi";
     return s;
}
> By the way, the example implements a real parser, which uses the 
> standard C++ runtime to convert the real number into a double. I had to 
> implement this,
> because I found out, that the Spirit real_p parser creates numerically 
> different results from the standard runtime, i.e.
> parsing the string "1.8" delivers a number like 1.8000000532 using 
> Spirit, while the C++ runtime delivers something like 1.7999999973, 
> which is always closer
> to the real value. Please note, that these numbers are not accurate, 
> they are simply meant to demonstrate, what I mean.
Wow, that's a strong accusation ;-) Again, code please. I can't
seem to reproduce your result:
     parse("1.8", real_p[assign_a(d)]);
     std::cout.setf(std::ios::fixed|std::ios::left);
     std::cout.precision(15);
     std::cout << d << std::endl;
gives me:
     1.800000000000000
Hmmm... how about:
     parse("1.800000000000001", real_p[assign_a(d)];
gives me:
     1.800000000000001
Regards,
-- Joel de Guzman http://www.boostpro.com http://spirit.sf.net