From: stephan b. <sg...@us...> - 2004-12-28 21:59:20
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14504/src/s11n Modified Files: data_node_algo.h Log Message: Worked around a really weird type conversion problem caused by LexT(const T &) and S11nNode's use of map<string,LexT>. Index: data_node_algo.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/data_node_algo.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- data_node_algo.h 28 Dec 2004 04:18:52 -0000 1.4 +++ data_node_algo.h 28 Dec 2004 21:59:09 -0000 1.5 @@ -116,11 +116,42 @@ { typedef node_traits<NodeT> TR; typedef typename NodeT::child_list_type::const_iterator CIT; - CIT it = std::find_if( TR::children(parent).begin(), - TR::children(parent).end(), - same_name<NodeT>( name ) - ); - return (TR::children(parent).end() == it) ? 0 : *it; + CIT et = TR::children(parent).end(); + CIT it = TR::children(parent).begin(); + for( ; et != it; ++it ) + { + if( TR::name(*(*it)) == name ) + { + return *it; + } + } + +/************************************ + + Using find_if(), in some unusual circumstances: + +../include/pclasses/s11n/data_node_algo.h: In function `const NodeT* + P::s11n::find_child_by_name(const NodeT&, const std::string&) [with NodeT = + P::SIO::S11nNode]': +../include/pclasses/s11n/data_node_serialize.h:273: instantiated from `bool P::s11n::deserialize_subnode(const DataNodeType&, const std::string&,DeserializableT&) [with DataNodeType = P::SIO::S11nNode, DeserializableT = P::Time]' +../include/pclasses/s11n/proxy/Time_s11n.h:149: instantiated from here +../include/pclasses/s11n/data_node_algo.h:124: error: ISO C++ says that `bool + std::_List_iterator_base::operator==(const std::_List_iterator_base&) const' + and `bool P::Util::operator==(const P::Util::LexT&, const T&) [with T = + std::_List_iterator<P::SIO::S11nNode*, P::SIO::S11nNode* const&, + P::SIO::S11nNode* const*>]' are ambiguous even though the worst conversion + for the former is better than the worst conversion for the latter + +// it = std::find_if( TR::children(parent).begin(), +// et, +// same_name<NodeT>( name ) +// ); +// if( et == it ) +// { +// return (NodeT*)0; +// } +*******************************************/ + return 0; } /** @@ -140,11 +171,26 @@ { typedef node_traits<NodeT> TR; typedef typename NodeT::child_list_type::iterator IT; - IT it = std::find_if( TR::children(parent).begin(), - TR::children(parent).end(), - same_name<NodeT>( name ) - ); - return (TR::children(parent).end() == it) ? 0 : *it; + IT et = TR::children(parent).end(); + IT it = TR::children(parent).begin(); + for( ; et != it; ++it ) + { + if( TR::name(*(*it)) == name ) + { + return *it; + } + } + return 0; +// see notes in const version of this func: +// IT it = std::find_if( TR::children(parent).begin(), +// TR::children(parent).end(), +// same_name<NodeT>( name ) +// ); +// if( TR::children(parent).end() == it) +// { +// return (NodeT*)0; +// } +// return (NodeT *)*it; } |