
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 05/04/2010 03:58 AM, DE wrote:
Hm... I *think* I see it now. At least, some of the time I think I do. :-) Please check my understanding: you're suggesting that I use functions in base_integer to do the allocation, and have them call other functions in base_integer to do the things that are different between fixed_integer and the variable-length integers. But then override those functions in the fixed_integer classes, not as virtual functions, but using CRTP to call the overridden functions. Am I right?
let me try to explain
suppose the interface of all your concrete classes (i.e. 'integer', 'nothrow_integer' and 'fixed_integer') is homogeneous that is all classes have identical names for respective members with consistent semantics
Which it should be.
then each of the classes inherits the base class
template<typename type> class base_integer {};
in the following way
class integer : public base_integer<integer> {/*...*/};
Yes, I understand that part.
then you can write template functions for all types in the following manner:
template<typename int_type> void foo(const base_integer<int_type>&); template<typename type1, typename type2> void bar(const base_integer<type1>&, const base_integer<type2>&);
such functions will handle all types derived from base_integer providing their type as template argument
Ah, I see now. It wouldn't matter that there couldn't be a common base class that implements all the common functions, then. I wince slightly at the implied duplication of compiled code, but I think I see how I can minimize it. And of course, people will only get that code for the functions and types that they use.
[...] please think about it, it is a very powerful design technique, also it may solve a whole lot of troubles now and later
Yes, I can see some problems that it would solve already. It may take me a few days of playing with it to figure out the most optimal way to use this, but I like the concept.
i like this theme very much and will happily write more words on this on your demand
Thanks. I think I've got the basic idea, but if I get stuck, I'll ask. :-) - -- Chad Nelson Oak Circle Software, Inc. * * * -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkvgOj4ACgkQp9x9jeZ9/wTTRACfcHHviBwHSlnmyVWW3OsWCM6S 5Q8AoMO36g5Ks9mn7Y+jlM1avm+vqTG8 =SVyP -----END PGP SIGNATURE-----