[Spirit2x] symbols with std::basic_string

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

[Spirit2x] symbols with std::basic_string

CARL BARRON-3
I have a modified version of symbols for which I added needed  
functions to add or remove a basic_string as well as a const char * to/
from a symbols.

I have in symbols:

        template <class Tr,class Al>
        adder const & operator += (const std::basic_string<Char,Tr,Al> &str)
                {
                        return add(str);
                }
               
         remover const&
         operator-=(Char const* str)
         {
             return remove(str);
         }

        note that table.add(str) and table.remove(str) both work.  Strangely  
these ops are no-ops any idea why???


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

CARL BARRON-3

On Mar 3, 2009, at 12:23 AM, Carl Barron wrote:

> I have a modified version of symbols for which I added needed
> functions to add or remove a basic_string as well as a const char *  
> to/
> from a symbols.
>
> I have in symbols:
>
> template <class Tr,class Al>
> adder const & operator += (const std::basic_string<Char,Tr,Al> &str)
> {
> return add(str);
> }
>
> note that table.add(str) and table.remove(str) both work.  Strangely
> these ops are no-ops any idea why???


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Joel de Guzman-2
In reply to this post by CARL BARRON-3
Carl Barron wrote:

> I have a modified version of symbols for which I added needed  
> functions to add or remove a basic_string as well as a const char * to/
> from a symbols.
>
> I have in symbols:
>
> template <class Tr,class Al>
> adder const & operator += (const std::basic_string<Char,Tr,Al> &str)
> {
> return add(str);
> }
>
>          remover const&
>          operator-=(Char const* str)
>          {
>              return remove(str);
>          }
>
> note that table.add(str) and table.remove(str) both work.  Strangely  
> these ops are no-ops any idea why???

Sorry, you lost me. What are no-ops?

Regards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

CARL BARRON-3

On Mar 3, 2009, at 12:51 AM, Joel de Guzman wrote:

> Carl Barron wrote:
>> I have a modified version of symbols for which I added needed
>> functions to add or remove a basic_string as well as a const char *  
>> to/
>> from a symbols.
>>
>> I have in symbols:
>>
>> template <class Tr,class Al>
>> adder const & operator += (const std::basic_string<Char,Tr,Al> &str)
>> {
>> return add(str);
>> }
>>
>>         remover const&
>>         operator-=(Char const* str)
>>         {
>>             return remove(str);
>>         }
>>
>> note that table.add(str) and table.remove(str) both work.  Strangely
>> these ops are no-ops any idea why???
>
> Sorry, you lost me. What are no-ops?

    symbols<>   table;
    std::string  a("abc"),b("def");

    table.add(a); // works with my additions; but
    table += b;   // does not add add b to the table with op ++
(std::basic_string<.,..>const &) above.



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Hartmut Kaiser
> > Carl Barron wrote:
> >> I have a modified version of symbols for which I added needed
> >> functions to add or remove a basic_string as well as a const char *
> >> to/
> >> from a symbols.
> >>
> >> I have in symbols:
> >>
> >> template <class Tr,class Al>
> >> adder const & operator += (const std::basic_string<Char,Tr,Al>
> &str)
> >> {
> >> return add(str);
> >> }
> >>
> >>         remover const&
> >>         operator-=(Char const* str)
> >>         {
> >>             return remove(str);
> >>         }
> >>
> >> note that table.add(str) and table.remove(str) both work.
> Strangely
> >> these ops are no-ops any idea why???
> >
> > Sorry, you lost me. What are no-ops?
>
>     symbols<>   table;
>     std::string  a("abc"),b("def");
>
>     table.add(a); // works with my additions; but
>     table += b;   // does not add add b to the table with op ++
> (std::basic_string<.,..>const &) above.

Seems the proto operator+=() overload takes precedence, hiding your
operator? Try defining a global operator instead.

Regards Hartmut




------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

CARL BARRON-3

On Mar 3, 2009, at 5:12 AM, Hartmut Kaiser wrote:

>>> Carl Barron wrote:
>>>> I have a modified version of symbols for which I added needed
>>>> functions to add or remove a basic_string as well as a const char *
>>>> to/
>>>> from a symbols.
>>>>
>>>> I have in symbols:
>>>>
>>>> template <class Tr,class Al>
>>>> adder const & operator += (const std::basic_string<Char,Tr,Al>
>> &str)
>>>> {
>>>> return add(str);
>>>> }
>>>>
>>>>        remover const&
>>>>        operator-=(Char const* str)
>>>>        {
>>>>            return remove(str);
>>>>        }
>>>>
>>>> note that table.add(str) and table.remove(str) both work.
>> Strangely
>>>> these ops are no-ops any idea why???
>>>
>>> Sorry, you lost me. What are no-ops?
>>
>>    symbols<>   table;
>>    std::string  a("abc"),b("def");
>>
>>    table.add(a); // works with my additions; but
>>    table += b;   // does not add add b to the table with op ++
>> (std::basic_string<.,..>const &) above.
>
> Seems the proto operator+=() overload takes precedence, hiding your
> operator? Try defining a global operator instead.

   Unfortunately it makes no difference.
        template
        <
                typename Char,
                typename T,
                typename Lookup,
                typename Filter,
                typename Tr,
                typename Al
        >
        typename symbols<Char,T,Lookup,Filter>::adder const &
        operator +=(symbols<Char,T,Lookup,Filter>  
&s,std::basic_string<Char,Tr,Al> const &str)
        {
                return  s.add(str);
        }
       
        template
        <
                typename Char,
                typename T,
                typename Lookup,
                typename Filter,
                typename Tr,
                typename Al
        >
        typename symbols<Char,T,Lookup,Filter>::remover const &
        operator -= (symbols<Char,T,Lookup,Filter>  
&s,std::basic_string<Char,Tr,Al> const &str)
        {
                return s.remove(str);
        }

are still no ops in that they do not change s.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Joel de Guzman-2
Carl Barron wrote:
>> Seems the proto operator+=() overload takes precedence, hiding your
>> operator? Try defining a global operator instead.
>
>    Unfortunately it makes no difference.

You need a non-const overload. Anyway, I did a proper fix to allow
what you intend. Committed to SVN Spirit2x. My version does it
properly by going through support/string_traits.hpp which can be
user-tweaked to allow for user string types. I added your test
to the symbols.cpp test.

HTH.

Regards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Francois Barel
Joel de Guzman wrote:
> You need a non-const overload. Anyway, I did a proper fix to allow
> what you intend. Committed to SVN Spirit2x. My version does it
> properly by going through support/string_traits.hpp which can be
> user-tweaked to allow for user string types. I added your test
> to the symbols.cpp test.

Sweet, now we can do sym1.for_each(sym2.add) to merge symbol tables :)
This solves ticket #2397 (although maybe it would be better to wait
until Spirit2X is moved to Boost svn to close the ticket?)

Small complaint though: adding other string types (such as MFC
CString's) worked natively before, as long as they have a conversion
to Char* -- but it doesn't work anymore.
What do you think about the attached patch? It adds a new default,
take-all overload to get_begin/get_end -- so that the appropriate
operator Char* is tried if the string is neither a Char* nor a
basic_string<Char>.

And a final question: is there a specific reason the method "adder
const& operator=(Char const* str)" wasn't made generic w.r.t. string
types like others, or was it missed?

Thanks,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Francois Barel
Francois Barel wrote:
> Small complaint though: adding other string types (such as MFC
> CString's) worked natively before, as long as they have a conversion
> to Char* -- but it doesn't work anymore.
> What do you think about the attached patch? It adds a new default,
> take-all overload to get_begin/get_end -- so that the appropriate
> operator Char* is tried if the string is neither a Char* nor a
> basic_string<Char>.

It's even better if I actually attach the patch, sorry...

Regards,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

Spirit2X-string_traits.patch (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Joel de Guzman-2
In reply to this post by Francois Barel
Francois Barel wrote:

> Joel de Guzman wrote:
>> You need a non-const overload. Anyway, I did a proper fix to allow
>> what you intend. Committed to SVN Spirit2x. My version does it
>> properly by going through support/string_traits.hpp which can be
>> user-tweaked to allow for user string types. I added your test
>> to the symbols.cpp test.
>
> Sweet, now we can do sym1.for_each(sym2.add) to merge symbol tables :)
> This solves ticket #2397 (although maybe it would be better to wait
> until Spirit2X is moved to Boost svn to close the ticket?)

I think we can close it now, if that fixed it.

> Small complaint though: adding other string types (such as MFC
> CString's) worked natively before, as long as they have a conversion
> to Char* -- but it doesn't work anymore.
> What do you think about the attached patch? It adds a new default,
> take-all overload to get_begin/get_end -- so that the appropriate
> operator Char* is tried if the string is neither a Char* nor a
> basic_string<Char>.

Feel free to patch the code.

> And a final question: is there a specific reason the method "adder
> const& operator=(Char const* str)" wasn't made generic w.r.t. string
> types like others, or was it missed?

Ooops. Feel free to fix this one too :-P

Regards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Joel de Guzman-2
In reply to this post by Francois Barel
Francois Barel wrote:

> Francois Barel wrote:
>> Small complaint though: adding other string types (such as MFC
>> CString's) worked natively before, as long as they have a conversion
>> to Char* -- but it doesn't work anymore.
>> What do you think about the attached patch? It adds a new default,
>> take-all overload to get_begin/get_end -- so that the appropriate
>> operator Char* is tried if the string is neither a Char* nor a
>> basic_string<Char>.
>
> It's even better if I actually attach the patch, sorry...

It would be good to provide a short comment in string_traits.hpp
explaining the intent. Otherwise, it looks good.

Regards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

CARL BARRON-3
In reply to this post by Francois Barel

On Mar 4, 2009, at 8:43 AM, Francois Barel wrote:

> Joel de Guzman wrote:
>> You need a non-const overload. Anyway, I did a proper fix to allow
>> what you intend. Committed to SVN Spirit2x. My version does it
>> properly by going through support/string_traits.hpp which can be
>> user-tweaked to allow for user string types. I added your test
>> to the symbols.cpp test.
>
> Sweet, now we can do sym1.for_each(sym2.add) to merge symbol tables :)
> This solves ticket #2397 (although maybe it would be better to wait
> until Spirit2X is moved to Boost svn to close the ticket?)
>
> Small complaint though: adding other string types (such as MFC
> CString's) worked natively before, as long as they have a conversion
> to Char* -- but it doesn't work anymore.
> What do you think about the attached patch? It adds a new default,
> take-all overload to get_begin/get_end -- so that the appropriate
> operator Char* is tried if the string is neither a Char* nor a
> basic_string<Char>.
>
> And a final question: is there a specific reason the method "adder
> const& operator=(Char const* str)" wasn't made generic w.r.t. string
> types like others, or was it missed?


I don't like your patch, seems better to do it right via template  
specialization
after all that is what the traits namespace was designed to be used,  
[At least I think
it was :)]

//  mfc_strings,hpp
// include guards ommitted
#include <boost/spirit/home/support/string_traits.hpp>

// add mfc CString to traits


namespace boost{namespace spirit{namespace traits{

template <> struct is_string<CString> :mpl::true_{};
template <> struct char_type_of<CString>:mpl::identity<char>{};

inline char * get_c_string(CString &str) { return Str;}

inline char * get_begin(CString &str) { return Str;}

inline char * get_end(CSTring &str)
{
        // there may be a better way but this should work
        char *p = str;
        return get_end(p);
}

}}}

// end of file

now more details

is_string is derived from mpl;:false_ unless it is a string and then  
it is derived from mpl::true_.


char_type is derived from mpl;:identity<char type containded in the  
string>

inline  T * get_c_string( string_type &x)  returns a T() [I guess in  
general] terminated array of T.

inline XXX  get_begin(string type &)
inline XXX  get_end(string type &)    return beginning and ending  
iterators of the string type.


fairly simple and now no problem since I assume your error was no  
function get_begin(CString const &);  before your patch .


Now if good_stuff::rope has both a conversion to char * [not efficient  
but present for some reason] and beginning and ending iterators, it  
won't blindly use the poor implementation of
converting to a char *, but actually return the iterators desired in  
the first place more efficiently....



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

CARL BARRON-3
In reply to this post by Francois Barel

On Mar 4, 2009, at 8:43 AM, Francois Barel wrote:
> And a final question: is there a specific reason the method "adder
> const& operator=(Char const* str)" wasn't made generic w.r.t. string
> types like others, or was it missed?


   I skipped it until we had a working solution to probably more  
useful op +=() op -=().

   template <class Sym,class T>
   friend adder & operator = (Sym &sym,T &t)
   {
        sym.lookup->clear();
        return sym.add(traits::get_begin(t),traits::get_end(t));
   }

looks right,


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Francois Barel
In reply to this post by CARL BARRON-3
Carl Barron wrote:
> I don't like your patch, seems better to do it right via template
> specialization
> after all that is what the traits namespace was designed to be used,
> [At least I think
> it was :)]

Sure, but on the other hand it would be nice to avoid having to write
specific code / include an extra header for such a common case (not
just CString -- surely it's not the only custom string type to have a
Char* conversion).
Furthermore I haven't looked in detail, but including / detecting
CString may not be that easy, IIRC the containing headers and the
exact type name have changed over the years / VC++ versions.

Also I don't really like being that specific about types, it somewhat
defeats the nice thing about templates: as long as a custom type is
compatible / has the appropriate API, we should be able to "just use
it" (unless of course there is an explicit specialization for that
type) -- e.g. that's done in Spirit2X with the notion of compatibles
attributes. Of course there can be debate on what this 'appropriate
API" is.


> Now if good_stuff::rope has both a conversion to char * [not efficient
> but present for some reason] and beginning and ending iterators, it
> won't blindly use the poor implementation of
> converting to a char *, but actually return the iterators desired in
> the first place more efficiently....

Fair point. I'm not sure how often people use a rope to initialize a
symbol table :p but anyway... I can try and rework the patch to use
iterators if they are supported by the type, and only fall back to
Char* conversion if they are not.
Of course this doesn't prevent explicit specialization if a custom
type has a better implementation, but I think it's good to natively
accept types with iterators and types with a Char* conversion.

What do you think?

Regards,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Joel de Guzman-2
Francois Barel wrote:

> Carl Barron wrote:
>> I don't like your patch, seems better to do it right via template
>> specialization
>> after all that is what the traits namespace was designed to be used,
>> [At least I think
>> it was :)]
>
> Sure, but on the other hand it would be nice to avoid having to write
> specific code / include an extra header for such a common case (not
> just CString -- surely it's not the only custom string type to have a
> Char* conversion).
> Furthermore I haven't looked in detail, but including / detecting
> CString may not be that easy, IIRC the containing headers and the
> exact type name have changed over the years / VC++ versions.
>
> Also I don't really like being that specific about types, it somewhat
> defeats the nice thing about templates: as long as a custom type is
> compatible / has the appropriate API, we should be able to "just use
> it" (unless of course there is an explicit specialization for that
> type) -- e.g. that's done in Spirit2X with the notion of compatibles
> attributes. Of course there can be debate on what this 'appropriate
> API" is.

I agree. I do not want to pull in CString (or any other concrete type)
unless absolutely necessary. In this case, I think it is not. I see
nothing wrong with a good default.

>> Now if good_stuff::rope has both a conversion to char * [not efficient
>> but present for some reason] and beginning and ending iterators, it
>> won't blindly use the poor implementation of
>> converting to a char *, but actually return the iterators desired in
>> the first place more efficiently....
>
> Fair point. I'm not sure how often people use a rope to initialize a
> symbol table :p but anyway... I can try and rework the patch to use
> iterators if they are supported by the type, and only fall back to
> Char* conversion if they are not.
> Of course this doesn't prevent explicit specialization if a custom
> type has a better implementation, but I think it's good to natively
> accept types with iterators and types with a Char* conversion.
>
> What do you think?

Again, agreed.

Regards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Francois Barel
In reply to this post by CARL BARRON-3
Carl Barron wrote:

>   I skipped it until we had a working solution to probably more
> useful op +=() op -=().
>
>   template <class Sym,class T>
>   friend adder & operator = (Sym &sym,T &t)
>   {
>        sym.lookup->clear();
>        return sym.add(traits::get_begin(t),traits::get_end(t));
>   }
>
> looks right,

Done in svn r1901 (not as a friend though, operator= can't be one).

Regards,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Francois Barel
In reply to this post by Joel de Guzman-2
Joel de Guzman wrote:

> Francois Barel wrote:
>> Fair point. I'm not sure how often people use a rope to initialize a
>> symbol table :p but anyway... I can try and rework the patch to use
>> iterators if they are supported by the type, and only fall back to
>> Char* conversion if they are not.
>> Of course this doesn't prevent explicit specialization if a custom
>> type has a better implementation, but I think it's good to natively
>> accept types with iterators and types with a Char* conversion.
>>
>> What do you think?
>
> Again, agreed.

Committed in svn r1094. Now traits::get_begin/get_end:
- still handle C-style strings directly (returning pointers),
- handle all containers with .begin()/.end() (returning iterators) --
basic_string's are now treated like any other container,
- and for unknown types, by default (unless additional, specific
overloads are provided for those types), attempt C-style string
conversion.

Regards,
François

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2x] symbols with std::basic_string

Joel de Guzman-2
Francois Barel wrote:

> Joel de Guzman wrote:
>> Francois Barel wrote:
>>> Fair point. I'm not sure how often people use a rope to initialize a
>>> symbol table :p but anyway... I can try and rework the patch to use
>>> iterators if they are supported by the type, and only fall back to
>>> Char* conversion if they are not.
>>> Of course this doesn't prevent explicit specialization if a custom
>>> type has a better implementation, but I think it's good to natively
>>> accept types with iterators and types with a Char* conversion.
>>>
>>> What do you think?
>> Again, agreed.
>
> Committed in svn r1094. Now traits::get_begin/get_end:
> - still handle C-style strings directly (returning pointers),
> - handle all containers with .begin()/.end() (returning iterators) --
> basic_string's are now treated like any other container,
> - and for unknown types, by default (unless additional, specific
> overloads are provided for those types), attempt C-style string
> conversion.

Tks Francois!

Regards,
--
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel