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

Discussion in 'C++' started by Misiu, Jan 31, 2007.

  1. Misiu

    Misiu Guest

    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> >));
    ....
    }
    Misiu, Jan 31, 2007
    #1
    1. Advertising

  2. 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.
    Mathias Gaunard, Jan 31, 2007
    #2
    1. Advertising

  3. "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
    Sylvester Hesp, Jan 31, 2007
    #3
  4. Misiu

    Misiu Guest

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

    Thanks a lot.
    Misiu
    Misiu, Jan 31, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. marco_segurini
    Replies:
    3
    Views:
    2,284
    Karl Heinz Buchegger
    Jul 7, 2004
  2. ma740988
    Replies:
    18
    Views:
    1,022
    Daniel T.
    Jan 30, 2006
  3. Toby Bradshaw
    Replies:
    6
    Views:
    1,747
    Kai-Uwe Bux
    Jun 2, 2006
  4. Anonymous
    Replies:
    9
    Views:
    705
    =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
    Oct 26, 2007
  5. Nick Keighley

    trouble with std::find_if()

    Nick Keighley, Jul 2, 2008, in forum: C++
    Replies:
    1
    Views:
    371
    Nick Keighley
    Jul 2, 2008
Loading...

Share This Page