
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi! Am 15.02.12 23:59, schrieb Robert Ramey:
well, I wrote the above in about a minute to illustrate that the job is trivial.
Too many things seem trivial.
Of course I'd have to spend a little more time to get it exactly right. So after another minute I came up with this which does compile without error on my MSVC system.
I wonder. I guess you never instantiated your template.
const T & find(const T & t){ static bool sorted = false; if(! sorted){ std::sort(begin(), end()); sorted = true; } return std::bsearch(begin(), end(), t); };
Given the above interface I propose a simpler implementation: template<class T, class A> class fast_set : public std::vector<T, A> { const T & find(const T & t){ return t; }; }; This also removes errors with the static bool variable. Point is: how long does it take you to get it right? How many other people does it take to get it right (without reviews you won't get it right, or it takes long)? Frank -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: keyserver x-hkp://pool.sks-keyservers.net iEYEARECAAYFAk88PEIACgkQhAOUmAZhnmoA/QCgiNF5/doGGq8cFpIg5sdCvweK pOEAn1BtLGWpcoXEzQzzsxDIjVRQRjWf =Eati -----END PGP SIGNATURE-----