regex and tokenizer, something wrong with namspace ?
Hi,
I am a new user of the boost library (Actually with VC6 SP5 and
stlport 4.0). Everything goes well when I use tokenizer and
regexp in separated programs.
But when I want to use the regex and the tokenizer library
together I can not compile. for example, if I take the
$(BOOST_ROOT)/libs/tokenizer/examples.cpp from John R. Bandela
and just add the include line:
#include ::is_ret(char) const'
Error executing cl.exe. examples.exe - 1 error(s), 0 warning(s)
any idees ?
Alexandre
But when I want to use the regex and the tokenizer library together I can not compile. for example, if I take the $(BOOST_ROOT)/libs/tokenizer/examples.cpp from John R. Bandela and just add the include line:
#include
the compiler gives me this error: ...
I suspect the problem may either be a compiler or configuration issue. I tried out your experiment with boost_1_25_0, g++ 2.95.2 under cygwin, and STLPort4.0 and it compiles fine. Just searching the header files, there is only one ispunct (which is defined in std::) and that is in token_functions.hpp, so there is no direct clash between the libraries. Good luck, Jeff
Thanks Jeff, but I guess it is this stupid MSVC compiler. I just done what I does not want to do (but it works fine), turning using namespace directive into scope resolution operator inside "token_functions.hpp": bool is_ret(Char E)const { if(returnable_.length()) return returnable_.find(E) != string_type::npos; else{ if(no_ispunct_){return false;} else{ //using namespace std; //int r = ispunct(E); int r = std::ispunct(E); return r != 0; } } } bool is_nonret(Char E)const { if(nonreturnable_.length()) return nonreturnable_.find(E) != string_type::npos; else{ if(no_isspace_){return false;} else{ //using namespace std; //int r = isspace(E); int r = std::isspace(E); return r != 0; } } } I try this little program inside MSVC and it work fine. I does not understand what is going on inside "token_functions.hpp"! #include <string> #include <iostream> void f(); int main(int argc, char* argv[]) { f(); return 0; } #define xxx std; void f() { using namespace xxx; string a; a.assign("hello"); cout << a << endl; }
Alexandre -
Thanks Jeff, but I guess it is this stupid MSVC compiler. I just done what I does not want to do (but it works fine), turning using namespace directive into scope resolution operator inside "token_functions.hpp":
Actually, I believe std::ispunct is a better implementation than the current one that uses "using". Just so I understand, did this change work? If so, it should be suggested as a change to the library.
I try this little program inside MSVC and it work fine. I does not understand what is going on inside "token_functions.hpp"!
#include <string> #include <iostream>
void f();
int main(int argc, char* argv[]) { f(); return 0; }
#define xxx std;
void f() { using namespace xxx; string a; a.assign("hello"); cout << a << endl; }
I don't understand what you are trying to do here or what this has to do with regex/tokenizer? Jeff
Actually, I believe std::ispunct is a better implementation than the current one that uses "using". Just so I understand, did this change work? If so, it should be suggested as a change to the library.
I don't think so. I think that we must understand what
going on because
the piece of code below works neither with std:: and
namespace (on MSVC6)!
#include<iostream>
#include
I don't understand what you are trying to do here or what this has to do with regex/tokenizer?
I readed that boost turns _STD:: into std:: with macro, so I try the same in my small test program just trying to see if using namespace directive inside a brace's bloc is supported by the MSVC compiler. Alex ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Courrier : http://courrier.yahoo.fr
I readed that boost turns _STD:: into std:: with macro, so I try the same in my small test program just trying to see if using namespace directive inside a brace's bloc is supported by the MSVC compiler.
Ok, now I understand this part, but just to clarify, it is STLPort not Boost that uses this macro. Jeff
Ok, now I understand this part, but just to clarify, it is STLPort not Boost that uses this macro.
Thanks for correct me, I'am just tired working since this morning (and it is now 18h in France)! And what about the other part ? ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Courrier : http://courrier.yahoo.fr
Thanks for correct me, I'am just tired working since this morning (and it is now 18h in France)! And what about the other part ?
Well, I don't see anything obviously wrong, but if I were you I would try taking out all the using statements and qualify all the names. I'm not an expert on the issues with MSVC, but I suspect that 'using' may have more problems than directly qualified names. And if that doesn't work I would get some rest :-) Jeff
participants (3)
-
acarsac@yahoo.fr
-
Alexandre Carsac
-
Jeff Garland