|
Boost Users : |
Subject: Re: [Boost-users] [Spirit] qi::parse at translation unit global scope?
From: Vitaly Budovski (vbudovski+news_at_[hidden])
Date: 2012-02-01 05:54:28
On 1 February 2012 20:33, Olaf Meeuwissen <olaf.meeuwissen_at_[hidden]> wrote:
> I noticed this when I played around with wrapping qi::parse() in a
> parse() function that does some things before and after qi::parse().
>
> My code had been calling qi::parse(), with the `qi::` namespace prefix,
> everywhere so I removed from a few calls and compiled before adding a
> parse() declaration. Â Lo and behold, compilation unexpectedly succeeded.
> I've reduced the behaviour in a minimalistic sample program (attached).
>
> I expect their to be *no* parse() function within the scope of main().
> Can anyone clarify why the compiler has no trouble finding one and which
> one it finds?
>
> Adding a global scope operator to the call, i.e. saying ::parse(), does
> result in the expected compile error.
>
> Using Boost 1.46.1, gcc 4.6.2 on Debian wheezy.
>
> Thanks in advance,
> --
> Olaf Meeuwissen, LPIC-2 Â Â Â Â Â FLOSS Engineer -- AVASYS CORPORATION
> FSF Associate Member #1962 Â Â Â Â Â Â Â Help support software freedom
> Â Â Â Â Â Â Â Â http://www.fsf.org/jf?referrer=1962
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
The compiler uses Argument Dependent Lookup (ADL) to determine which
function to call. One of the parameters is qi::rule, so the compiler
looks in that namespace for a matching parse function.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net