Re: Is this correct C++ code (Boost pool allocator with "const
std::string" key)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi!
Am 08.05.12 20:22, schrieb Roman W:
{ reformatted; please limit your lines to 70 characters -mod }
The following code compiles under g++ 4.5.3, but does not under MS
Visual Studio 2008:
[snip]
Where "reference" and "const reference" are defined as
typedef value_type & reference; typedef const value_type &
const_reference;
In this case, "value_type" is "const K" where "K" == "const
std::string".
I think this code should be rejected. "const int&" and "const const
int&" are the same type. Thus the function signature is also the same
which leads to an error.
It's up to boost to check your usecase and fix the boost code
accordingly. You might want to open an issue on their bug tracker.
// rejected by comeau online 4.3.10.1 Beta2:
// rejected by clang-3.2:
// rejected by gcc-4.6.3:
template<typename T>
struct Foo
{
void run(T&) {}
void run(T const&) {}
};
int main()
{
Foo<const int> f;
}
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: keyserver x-hkp://pool.sks-keyservers.net
iEYEARECAAYFAk+zPnwACgkQhAOUmAZhnmqKGACdHRQG+32tQ2tSmciP7MTXQ0d8
D5UAnijj+tDxyY69BGrZpM13mwoPTT8R
=swna
-----END PGP SIGNATURE-----
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]