Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Boost::any and boost::lambda with std::find_if

Reply
Thread Tools

Boost::any and boost::lambda with std::find_if

 
 
Misiu
Guest
Posts: n/a
 
      01-31-2007
Hello everybody,

How to avoid using struct IsDataType for comparison for find_if
algorithm but use something like that what is now commented out in the
code below?

Regards,
Misiu

template<typename T>
struct IsDataType
{
bool operator() (const boost::any& operand)
{
return (operand.type() ==
typeid(boost::shared_ptr<DataDistributor<T> >));
}
};

template<typename T>
static DataDistributor<T>* GetDataDistributor()
{
std::list<boost::any>::iterator iter =
std::find_if(m_distrubutors.begin(), m_distrubutors.end(),
IsDataType<T>());

//error C2248: 'type_info::type_info' : cannot access private member
//declared in class 'type_info' boost\tuple\detail\tuple_basic.hpp 477

// std::find_if(m_distrubutors.begin(), m_distrubutors.end(),
// boost::lambda::bind(&boost::any::type, _1) ==
// typeid(boost::shared_ptr<DataDistributor<T> >));
....
}
 
Reply With Quote
 
 
 
 
Mathias Gaunard
Guest
Posts: n/a
 
      01-31-2007
Misiu wrote:
> Hello everybody,
>
> How to avoid using struct IsDataType for comparison for find_if
> algorithm but use something like that what is now commented out in the
> code below?


You should ask on the boost mailing list.

 
Reply With Quote
 
 
 
 
Sylvester Hesp
Guest
Posts: n/a
 
      01-31-2007

"Misiu" <> wrote in message news:epq0qf$6l0$...
> Hello everybody,
>
> How to avoid using struct IsDataType for comparison for find_if algorithm
> but use something like that what is now commented out in the code below?
>
> Regards,
> Misiu
>
> template<typename T>
> struct IsDataType
> {
> bool operator() (const boost::any& operand)
> {
> return (operand.type() ==
> typeid(boost::shared_ptr<DataDistributor<T> >));
> }
> };
>
> template<typename T>
> static DataDistributor<T>* GetDataDistributor()
> {
> std::list<boost::any>::iterator iter =
> std::find_if(m_distrubutors.begin(), m_distrubutors.end(),
> IsDataType<T>());
>
> //error C2248: 'type_info::type_info' : cannot access private member
> //declared in class 'type_info' boost\tuple\detail\tuple_basic.hpp 477
> // std::find_if(m_distrubutors.begin(), m_distrubutors.end(),
> // boost::lambda::bind(&boost::any::type, _1) ==
> // typeid(boost::shared_ptr<DataDistributor<T> >));
> ...
> }


You can't copy-construct a type_info structure. You'll need boost::ref.

- Sylvester


 
Reply With Quote
 
Misiu
Guest
Posts: n/a
 
      01-31-2007
>
> You can't copy-construct a type_info structure. You'll need boost::ref.
>

Thanks a lot.
Misiu
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if and and vs if and,and titi VHDL 4 03-11-2007 05:23 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57