Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.c++
Function address vs. pointer to member function
Ramon F Herrera
9/18/2009 4:18:00 PM
(please refer to the thread "Having trouble trying to get the address
of a member function" for details)
The following sample program comes with the C++ Regex distribution. It
compiles and runs fine. Its purpose is to count the number of classes
in the input text file.
http://patriot.net/~ramon/regex_iterator_examp...
I am having a real hard time trying to convert the code to a class.
The problem occurs in this statement:
std::for_each(m1, m2, ®ex_callback);
Thanks,
-Ramon
http://www.parashift.com/c++-faq-lite/pointers-to-me...
2 Answers
Ramon F Herrera
9/18/2009 6:44:00 PM
0
On Sep 18, 12:17 pm, Ramon F Herrera <ra...@conexus.net> wrote:
> (please refer to the thread "Having trouble trying to get the address
> of a member function" for details)
>
> The following sample program comes with the C++ Regex distribution. It
> compiles and runs fine. Its purpose is to count the number of classes
> in the input text file.
>
>
http://patriot.net/~ramon/regex_iterator_examp...
>
> I am having a real hard time trying to convert the code to a class.
> The problem occurs in this statement:
>
> std::for_each(m1, m2, ®ex_callback);
>
> Thanks,
>
> -Ramon
>
>
http://www.parashift.com/c++-faq-lite/pointers-to-me...
Found a solution ("the" solution?). It was provided by the author of
the Boost.Regex library.
Due respect, but I don't like that kind of hacks at all. Will keep
that code outside of a class, as if it was C.
-Ramon
--------------------
#if BOOST_WORKAROUND(_MSC_VER, < 1300) && !defined(_STLP_VERSION)
boost::regex_grep(std::bind1st(std::mem_fun1
(&class_index::grep_callback), this),
start,
end,
expression);
#else
boost::regex_grep(std::bind1st(std::mem_fun
(&class_index::grep_callback), this),
start,
end,
expression);
#endif
}
pjb
9/21/2009 8:52:00 AM
0
Ramon F Herrera <ramon@conexus.net> writes:
> On Sep 18, 12:17 pm, Ramon F Herrera <ra...@conexus.net> wrote:
>> (please refer to the thread "Having trouble trying to get the address
>> of a member function" for details)
>>
>> The following sample program comes with the C++ Regex distribution. It
>> compiles and runs fine. Its purpose is to count the number of classes
>> in the input text file.
>>
>>
http://patriot.net/~ramon/regex_iterator_examp...
>>
>> I am having a real hard time trying to convert the code to a class.
>> The problem occurs in this statement:
>>
>> std::for_each(m1, m2, ®ex_callback);
>>
>> Thanks,
>>
>> -Ramon
>>
>>
http://www.parashift.com/c++-faq-lite/pointers-to-me...
>
>
> Found a solution ("the" solution?). It was provided by the author of
> the Boost.Regex library.
>
> Due respect, but I don't like that kind of hacks at all. Will keep
> that code outside of a class, as if it was C.
Then you still haven't understood what OO is all about.
On the contrary, you should use classes to encapsulate all these kinds
of hacks! That's exactly what they were designed for!
So you can thereafter use these classes with a homogeneous look and
feel, and without having to use or see these hacks anymore.
--
__Pascal Bourguignon__
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Function address vs. pointer to member function
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password