(*&#@*!^ Templates
-
I've been trying to use the Boost serialization library to make some data persistent. Nothing particularly fancy but I have some objects from the wxWidgets library included. What a PITA! Ok, I admit I may be a bit late to the party. I've dabbled a little with my own template classes over the years but nothing extensive as I've just not had the need. So I'm not nearly as facile with them as I am with the rest of the language. But when the compiler generates an error on a template, it would be nice if it gave you a half way decipherable description of the real problem. It also appears that the compiler doesn't even parse some of the stuff in the template declarations until it actually decides to instantiate it. You're down to one error in the compile and think you've got it knocked and her comes another cascade of a page of errors. Or actually one more error with a page of crap not telling you what's wrong. The Boost serialization library, IMNSHO, needs considerably more documentation and more extensive examples. :sigh: Thanks, I needed that. :cool:
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
-
I've been trying to use the Boost serialization library to make some data persistent. Nothing particularly fancy but I have some objects from the wxWidgets library included. What a PITA! Ok, I admit I may be a bit late to the party. I've dabbled a little with my own template classes over the years but nothing extensive as I've just not had the need. So I'm not nearly as facile with them as I am with the rest of the language. But when the compiler generates an error on a template, it would be nice if it gave you a half way decipherable description of the real problem. It also appears that the compiler doesn't even parse some of the stuff in the template declarations until it actually decides to instantiate it. You're down to one error in the compile and think you've got it knocked and her comes another cascade of a page of errors. Or actually one more error with a page of crap not telling you what's wrong. The Boost serialization library, IMNSHO, needs considerably more documentation and more extensive examples. :sigh: Thanks, I needed that. :cool:
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
...to the jungle. :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
...to the jungle. :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Finally! :doh: Guess I missed a const declaration on one of the templated member functions. Maybe if it had told me it had problems converting beteen const T& and T& rather than const T and T& or something like that, I might have tumbled to it. And left out some of the other garbage along the way. I guess the moral of the story is to unit test templated classes or classes with templated functions incrementally as you go and make sure they each work before you barge ahead because the compiler said everything is ok. Guess when I noticed that it wasn't warning me about an unused parameter, I should have been suspicious that it didn't really care. :^)
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
-
I've been trying to use the Boost serialization library to make some data persistent. Nothing particularly fancy but I have some objects from the wxWidgets library included. What a PITA! Ok, I admit I may be a bit late to the party. I've dabbled a little with my own template classes over the years but nothing extensive as I've just not had the need. So I'm not nearly as facile with them as I am with the rest of the language. But when the compiler generates an error on a template, it would be nice if it gave you a half way decipherable description of the real problem. It also appears that the compiler doesn't even parse some of the stuff in the template declarations until it actually decides to instantiate it. You're down to one error in the compile and think you've got it knocked and her comes another cascade of a page of errors. Or actually one more error with a page of crap not telling you what's wrong. The Boost serialization library, IMNSHO, needs considerably more documentation and more extensive examples. :sigh: Thanks, I needed that. :cool:
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
You're seeing one of the fundamental defects in programming with templates. Implementing them to the standard is just so freaking complicated that compiler designers don't seem to be able to issue decent diagnostics for them. The point at which they detect problems is so far removed from the original source that they can't associate the two. VC6 was notoriously bad about it (its template support was incomplete), and VS2003 wasn't a whole lot better. My main source of never-ending grief is ">>" versus ">{space}>". In some cases, the compiler will handle the first token as a shift operator, in others it's the tail end of a templated argument to a template. One issue with Boost is that it's pretty much all-or-nothing. Most of the Boost libraries do not like to be mixed with other libraries such as MFC or ATL. I've successfully used Boost.RegEx in an MFC app, but that's it. I would imagine Boost requires that your wxWidget objects have certain Boost-specified characteristics, and they don't. You might need to encapsulate them in your own objects for serialization purposes.
Software Zen:
delete this;
Fold With Us![^] -
You're seeing one of the fundamental defects in programming with templates. Implementing them to the standard is just so freaking complicated that compiler designers don't seem to be able to issue decent diagnostics for them. The point at which they detect problems is so far removed from the original source that they can't associate the two. VC6 was notoriously bad about it (its template support was incomplete), and VS2003 wasn't a whole lot better. My main source of never-ending grief is ">>" versus ">{space}>". In some cases, the compiler will handle the first token as a shift operator, in others it's the tail end of a templated argument to a template. One issue with Boost is that it's pretty much all-or-nothing. Most of the Boost libraries do not like to be mixed with other libraries such as MFC or ATL. I've successfully used Boost.RegEx in an MFC app, but that's it. I would imagine Boost requires that your wxWidget objects have certain Boost-specified characteristics, and they don't. You might need to encapsulate them in your own objects for serialization purposes.
Software Zen:
delete this;
Fold With Us![^]Gary R. Wheeler wrote:
Implementing them to the standard is just so freaking complicated that compiler designers don't seem to be able to issue decent diagnostics for them. The point at which they detect problems is so far removed from the original source that they can't associate the two.
I think that's a big reason I sat on the bench about them for so long. When I played with them in the past, I didn't really need them so it was more of an academic exercise. Then I just got frustrated with them and bagged it. I'm using VC++ 20008 now and it doesn't choke as much but diagnostics aren't much better.
Gary R. Wheeler wrote:
My main source of never-ending grief is ">>" versus ">{space}>".
I got bit on that one early and now, if I'm on my game, remember to look for it. Part of the whole finicky somewhat arcane notation which has to be just so or you're scratching your head again about compiler errors. :^)
Gary R. Wheeler wrote:
Most of the Boost libraries do not like to be mixed with other libraries such as MFC or ATL.
Gary R. Wheeler wrote:
I would imagine Boost requires that your wxWidget objects have certain Boost-specified characteristics, and they don't. You might need to encapsulate them in your own objects for serialization purposes.
Yes, ran into that one but fortunately so far I'm only serializing two, wxColor and wxString. I first tried deriving serializable classes from them but ran into problems. Now I just have a data container to shadow wxColor and create an instance to do the serialization at the point it's needed. For wxString, I convert it to an std::string and go from there. I'm sure as time goes on, I'll be building up the repetoire but that's a bridge that can be double crossed later. On top of that, I'm using OpenCV, too, with its own set of simple primitives but since it's a C API, it will be a bit easier as the data is public for most of it.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.