boost::trim Am I wrong?

I just write a simple test of trim: #include <string> #include <boost/algorithm/string.hpp> int main(){ using namespace std; string temp = " just test "; boost::trim(temp); return 0; } but it couldn't pass the compile, error was: [C++ Error] trim.hpp(233): E2285 Could not find a match for 'detail::trim_end(undefined,undefined,detail::is_classifiedF)' [C++ Error] trim.hpp(126): E2285 Could not find a match for 'detail::trim_begin(undefined,undefined,detail::is_classifiedF)' but when I move the "using namespace std;" out of main function: #include <string> #include <boost/algorithm/string.hpp> using namespace std; int main(){ string temp = " just test "; boost::trim(temp); return 0; } I don't know why?

Hi, On Mon, Jun 06, 2005 at 01:17:47PM +0800, Sheng QuanHu wrote:
I just write a simple test of trim:
#include <string> #include <boost/algorithm/string.hpp> int main(){ using namespace std; string temp = " just test "; boost::trim(temp); return 0; }
but it couldn't pass the compile, error was: [C++ Error] trim.hpp(233): E2285 Could not find a match for 'detail::trim_end(undefined,undefined,detail::is_classifiedF)' [C++ Error] trim.hpp(126): E2285 Could not find a match for 'detail::trim_begin(undefined,undefined,detail::is_classifiedF)'
but when I move the "using namespace std;" out of main function:
#include <string> #include <boost/algorithm/string.hpp> using namespace std; int main(){ string temp = " just test "; boost::trim(temp); return 0; }
I don't know why?
I'm not sure what the problem could be. But it seems like some bug in a compiler. So my first question is: What compiler do you use? Regards, Pavol

...
but it couldn't pass the compile, error was: [C++ Error] trim.hpp(233): E2285 Could not find a match for 'detail::trim_end(undefined,undefined,detail::is_classifiedF)' [C++ Error] trim.hpp(126): E2285 Could not find a match for 'detail::trim_begin(undefined,undefined,detail::is_classifiedF)'
... I'm not sure what the problem could be. But it seems like some bug in a compiler.
So my first question is: What compiler do you use?
BCB. I checked and it fails with 6.4 (the latest). More details are bellow. /Pavel [C++ Error] trim.hpp(233): E2285 Could not find a match for 'detail::trim_end<ForwardIteratorT,PredicateT>(undefined,undefined,detail::is_classifiedF)' Full parser context trim.hpp(228): decision to instantiate: void void trim_right_if<_STL::string,detail::is_classifiedF>(_STL::string &,detail::is_classifiedF) --- Resetting parser context for instantiation... Unit1.cpp(9): #include C:\boost\boost_1_33_0\boost/algorithm/string.hpp string.hpp(18): #include C:\boost\boost_1_33_0\boost/algorithm/string/trim.hpp trim.hpp(35): namespace boost trim.hpp(36): namespace algorithm trim.hpp(228): parsing: void void trim_right_if<_STL::string,detail::is_classifiedF>(_STL::string &,detail::is_classifiedF) [C++ Error] trim.hpp(126): E2285 Could not find a match for 'detail::trim_begin<ForwardIteratorT,PredicateT>(undefined,undefined,detail::is_classifiedF)' Full parser context trim.hpp(120): decision to instantiate: void void trim_left_if<_STL::string,detail::is_classifiedF>(_STL::string &,detail::is_classifiedF) --- Resetting parser context for instantiation... Unit1.cpp(9): #include C:\boost\boost_1_33_0\boost/algorithm/string.hpp string.hpp(18): #include C:\boost\boost_1_33_0\boost/algorithm/string/trim.hpp trim.hpp(35): namespace boost trim.hpp(36): namespace algorithm trim.hpp(120): parsing: void void trim_left_if<_STL::string,detail::is_classifiedF>(_STL::string &,detail::is_classifiedF)

On Mon, Jun 06, 2005 at 07:10:42PM +0200, Pavel Vozenilek wrote:
...
but it couldn't pass the compile, error was: [C++ Error] trim.hpp(233): E2285 Could not find a match for 'detail::trim_end(undefined,undefined,detail::is_classifiedF)' [C++ Error] trim.hpp(126): E2285 Could not find a match for 'detail::trim_begin(undefined,undefined,detail::is_classifiedF)'
... I'm not sure what the problem could be. But it seems like some bug in a compiler.
So my first question is: What compiler do you use?
BCB. I checked and it fails with 6.4 (the latest).
More details are bellow.
/Pavel
[C++ Error] trim.hpp(233): E2285 Could not find a match for 'detail::trim_end<ForwardIteratorT,PredicateT>(undefined,undefined,detail::is_classifiedF)' Full parser context trim.hpp(228): decision to instantiate: void void trim_right_if<_STL::string,detail::is_classifiedF>(_STL::string &,detail::is_classifiedF) --- Resetting parser context for instantiation... Unit1.cpp(9): #include C:\boost\boost_1_33_0\boost/algorithm/string.hpp string.hpp(18): #include C:\boost\boost_1_33_0\boost/algorithm/string/trim.hpp trim.hpp(35): namespace boost trim.hpp(36): namespace algorithm trim.hpp(228): parsing: void void trim_right_if<_STL::string,detail::is_classifiedF>(_STL::string &,detail::is_classifiedF) [C++ Error] trim.hpp(126): E2285 Could not find a match for 'detail::trim_begin<ForwardIteratorT,PredicateT>(undefined,undefined,detail::is_classifiedF)' Full parser context trim.hpp(120): decision to instantiate: void void trim_left_if<_STL::string,detail::is_classifiedF>(_STL::string &,detail::is_classifiedF) --- Resetting parser context for instantiation... Unit1.cpp(9): #include C:\boost\boost_1_33_0\boost/algorithm/string.hpp string.hpp(18): #include C:\boost\boost_1_33_0\boost/algorithm/string/trim.hpp trim.hpp(35): namespace boost trim.hpp(36): namespace algorithm trim.hpp(120): parsing: void void trim_left_if<_STL::string,detail::is_classifiedF>(_STL::string &,detail::is_classifiedF)
I'm just guessing, since I don't have much experience with borland compilers. It definitely seems as a compiler related problem. Problem can be related to way the function detail::trim_begin is called. I'm using relative access convetion. So I use detail::trim_begin(...). In some places it helped if the namespace was specified explicitly. So I can try to make a fix in the cvs, but I will need somebody to test it. Can you arrange it? Regards, Pavol

On Mon, Jun 06, 2005 at 08:53:35PM +0200, Pavol Droba wrote:
I'm just guessing, since I don't have much experience with borland compilers. It definitely seems as a compiler related problem. Problem can be related to way the function detail::trim_begin is called.
I'm using relative access convetion. So I use detail::trim_begin(...). In some places it helped if the namespace was specified explicitly.
So I can try to make a fix in the cvs, but I will need somebody to test it.
I have commited a fix for trim and case conversion. Can you please verify if it helped? Thanks, Pavol

"Pavol Droba" wrote:
It definitely seems as a compiler related problem.
BCB has many quirks.
I have commited a fix for trim and case conversion. Can you please verify if it helped?
No the bug was the same. Following changes are needed in the code: a) leading :: before namespace: ::boost::algorithm::detail::trim_begin( should be boost::algorithm::detail::trim_begin( everywhere (BCB doesn't like it). b) the begin() and end() needs to be fully qualified for BCB: boost::algorithm::detail::trim_end( boost::begin(Input), <<== here boost::end(Input), <<== here IsSpace ), on both places where compiler complains. c) The iterator needs to be explicitly declared. I rewrote it into: template<typename SequenceT, typename PredicateT> inline void trim_right_if(SequenceT& Input, PredicateT IsSpace) { SequenceT::iterator it = boost::algorithm::detail::trim_end(boost::begin(Input), boost::end(Input), IsSpace); Input.erase(it, boost::end(Input)); } and template<typename SequenceT, typename PredicateT> inline void trim_left_if(SequenceT& Input, PredicateT IsSpace) { SequenceT::iterator it = boost::algorithm::detail::trim_begin(boost::begin(Input), boost::end(Input), IsSpace); Input.erase(boost::begin(Input), it); } and then it compiles (with your latest CVS version). /Pavel
participants (3)
-
Pavel Vozenilek
-
Pavol Droba
-
Sheng QuanHu