![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Chris Frey wrote: Here's the template version of the patch, for evaluation. Applies to CVS. /// See operator[](const char*) for more caveats. - const ColData operator [](size_type i) const + template <class IndexT + const ColData operator [](IndexT i) const { I had a similar problem where properties could be accessed by their indeces or by their names. My first solution was also like this: one of the functions is plain method and the other is templated. But I later found out that there were some problems with it - it just worked on some compilers (or something like this, not sure what the problem was exactly, but I had to redo it) |
|
my final solution was two templated methods that use boost::enable_if & boost::mpl::not_ & boost::is_integral basicly, it enables int version for integral types and non-int for non-integral types. (obviously it's better to use enable_if and disable_if, but this combination has some problems on vc i think) in short it looks something like this: template<class T typename enable_if< is_integral<T>, return_type>::type operator[](const T& a){ ... } template<class T typename enable_if< not_<is_integral<T> >, return_type>::type operator[](const T& a){ ... } all the things used here (enable_if etc.) are really simple to implement. |
|
One another solution is to take only c-arays of chars, and not pointers (row[] is almost always used in this way: either row["c-array"] or const char a[] = "c-array"; row[a]) for this case something like this will work: template<unsigned int N return_type operator[](const char(&a)[N]){ ... } return_type operator[](unsigned int){ ... } |
#3
| |||||||
| |||||||
|
|
(btw, please feel free to reply to the list... I know the list config doesn't make that easy, but we need to have valuable input like yours archived) :-) |
|
I had a similar problem where properties could be accessed by their indeces or by their names. My first solution was also like this: one of the functions is plain method and the other is templated. But I later found out that there were some problems with it - it just worked on some compilers (or something like this, not sure what the problem was exactly, but I had to redo it) I'd be interested in what kind of errors the above patch could cause. |

|
I suppose the template/non-template could confuse some compilers. If so, we could get rid of non-template members completely, and make a specialization for the const char * version. That should work. |
|
I haven't tried my patch on windows, so I don't know if there are funky errors there. mysql++ can only be compiled on fairly recent compilers (VC7.0 doesn't even do it, so I hear), so maybe this is a non-issue, since all supported compilers may handle it. |
|
Could you run a test compile and let us know, on WinXP? |

|
That's good, because I don't think we can, or want to, add boost to the build dependencies. I'll have to read up on enable_if. Some of the things that boost manages to do with C++ really surprise me. I just looked at the new parameter library, and wow. :-) |
), but it's ok to rip off that|
template<unsigned int N return_type operator[](const char(&a)[N]){ ... } return_type operator[](unsigned int){ ... } This looks interesting, and similar to libpqxx, except for the templates. I think const char* behaviour is worth keeping though. |

. Not sure if it's ok like this
#4
| |||
| |||
|
|
I'd be interested in what kind of errors the above patch could cause. I don't remember, but I really had to redo it ![]() I suppose the template/non-template could confuse some compilers. If so, we could get rid of non-template members completely, and make a specialization for the const char * version. That should work. The problem is that there's no such thing as partial template specialization for members. If you have two templates with the same signature, there's good chance a wrong template gets selected (resulting in compile error or worse, wrong code being executed). For control of instantiation of templates SFINAE (substitution-failure-is-not-an-error) principle used. enable_if exploits this thing. |
|
Could you run a test compile and let us know, on WinXP? I don't know how to compile it !!! ![]() I'll look around for the patch on the list to be able to compile it, or I'll create my own project files from zero... |
#5
| |||
| |||
|
|
I'd be interested in what kind of errors the above patch could cause. I don't remember, but I really had to redo it ![]() I suppose the template/non-template could confuse some compilers. If so, we could get rid of non-template members completely, and make a specialization for the const char * version. That should work. The problem is that there's no such thing as partial template specialization for members. If you have two templates with the same signature, there's good chance a wrong template gets selected (resulting in compile error or worse, wrong code being executed). For control of instantiation of templates SFINAE (substitution-failure-is-not-an-error) principle used. enable_if exploits this thing. |
|
Could you run a test compile and let us know, on WinXP? I don't know how to compile it !!! ![]() I'll look around for the patch on the list to be able to compile it, or I'll create my own project files from zero... |
#6
| |||
| |||
|
|
Could you run a test compile and let us know, on WinXP? I don't know how to compile it !!! ![]() I'll look around for the patch on the list to be able to compile it, or I'll create my own project files from zero... The development site is: https://gna.org/projects/mysqlpp/ You can grab the latest makemake.bat file here: http://svn.gna.org/viewcvs/mysqlpp/trunk/ |
#7
| |||
| |||
|
|
For unix, if you're building from svn, you'll need to run all the autoconf tools. There is a 'bootstrap' script to make that easy. So far I haven't had any trouble with the autoconf side of things. To specify a different compiler, I use a command line like this (assuming I've built gcc-4.0.1 and installed it in /home/source5/rootdir-gcc401): ./configure --prefix=/usr/local \ CC=/home/source5/rootdir-gcc401/bin/gcc \ CPP=/home/source5/rootdir-gcc401/bin/cpp \ CXX=/home/source5/rootdir-gcc401/bin/g++ \ CXXCPP=/home/source5/rootdir-gcc401/bin/cpp I can use a compiler built in any old home directory using this. To run the results using a new compiler like gcc-4.0.1 when my system compiler is gcc-3.3.6, I have to do: export LD_LIBRARY_PATH=/home/source5/rootdir-gcc401/lib |
Most of the distributions have a readme that tells what
#8
| |||
| |||
|
|
Chris Frey wrote: For unix, if you're building from svn, you'll need to run all the autoconf tools. There is a 'bootstrap' script to make that easy. So far I haven't ^^^^^^^^^ |
|
After I downloaded mysqlpp using svn, what's the next step to do?? makemake.sh or configure?? I doesn't make alot of sence to me that it has boostrap script or all autoconf tools - I don't really know that therminology Most of the distributions have a readme that tells whatto do and almost always it's ./configure && make install clean with mysqlpp I don't know where to start from. (makemake.sh fails, there's no configure script etc.) |
|
software using the right compiler). With freebsd there's no need to specify extra LD_LIB_PATH etc, all is needed is to use g++34 instead of g++ - it figures out where correct library is located by itself... |
#9
| |||
| |||
|
|
README.vc says that makemake vc creates makefiles and builds libraries, |
|
running nmake produces this error: |
|
I installed mysql using windows installer. the installation dir isn't c:/mysql, how do I specify it, |
#10
| ||||
| ||||
|
|
There seem to be to many dirrectories that are hardcoded into makefiles: |
|
had to manually create config.h etc... |
|
I tried to run makemake.sh, |
|
After when I replaced /usr/bash with something suitable for me it gave out some warnings (line 32: [: ==: unary operator expected) |
![]() |
| Thread Tools | |
| Display Modes | |
| |