diff options
author | Brad King <brad.king@kitware.com> | 2005-04-13 12:08:54 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2005-04-13 12:08:54 (GMT) |
commit | 743ab3a05f0f73a5e01429feea1b1e5e3a423d8a (patch) | |
tree | 28304f48a6031b2b4ca181bec8c4248fae07e858 /Source/kwsys/kwsysPlatformCxxTests.cxx | |
parent | 1713c3fd19ba04a5f951a54d3af6cc70996d98e2 (diff) | |
download | CMake-743ab3a05f0f73a5e01429feea1b1e5e3a423d8a.zip CMake-743ab3a05f0f73a5e01429feea1b1e5e3a423d8a.tar.gz CMake-743ab3a05f0f73a5e01429feea1b1e5e3a423d8a.tar.bz2 |
ENH: Adding SGI hash_map and hash_set implementation ported from STL to KWSys. This also adds try-compiles for KWSYS_STL_HAS_ALLOCATOR_REBIND, KWSYS_CXX_HAS_FULL_SPECIALIZATION, KWSYS_CXX_HAS_MEMBER_TEMPLATES, and KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS.
Diffstat (limited to 'Source/kwsys/kwsysPlatformCxxTests.cxx')
-rw-r--r-- | Source/kwsys/kwsysPlatformCxxTests.cxx | 86 |
1 files changed, 71 insertions, 15 deletions
diff --git a/Source/kwsys/kwsysPlatformCxxTests.cxx b/Source/kwsys/kwsysPlatformCxxTests.cxx index 5d24766..c1feca1 100644 --- a/Source/kwsys/kwsysPlatformCxxTests.cxx +++ b/Source/kwsys/kwsysPlatformCxxTests.cxx @@ -1,3 +1,12 @@ +// Setup for tests that use result of stl namespace test. +#if defined(KWSYS_STL_HAVE_STD) +# if KWSYS_STL_HAVE_STD +# define kwsys_stl std +# else +# define kwsys_stl +# endif +#endif + #ifdef TEST_KWSYS_STL_HAVE_STD #include <list> void f(std::list<int>*) {} @@ -31,11 +40,6 @@ int main() { return 0; } #endif #ifdef TEST_KWSYS_STL_STRING_HAVE_OSTREAM -# if KWSYS_STL_HAVE_STD -# define kwsys_stl std -# else -# define kwsys_stl -# endif # include <iostream.h> # include <string> void f(ostream& os, const kwsys_stl::string& s) { os << s; } @@ -43,11 +47,6 @@ int main() { return 0; } #endif #ifdef TEST_KWSYS_STL_STRING_HAVE_ISTREAM -# if KWSYS_STL_HAVE_STD -# define kwsys_stl std -# else -# define kwsys_stl -# endif # include <iostream.h> # include <string> void f(istream& is, kwsys_stl::string& s) { is >> s; } @@ -55,16 +54,73 @@ int main() { return 0; } #endif #ifdef TEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR -# if KWSYS_STL_HAVE_STD -# define kwsys_stl std -# else -# define kwsys_stl -# endif # include <string> bool f(const kwsys_stl::string& s) { return s != ""; } int main() { return 0; } #endif +#ifdef TEST_KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS +template <class T> class A; +template <class T> int f(A<T>&); +template <class T> class A +{ +public: + // "friend int f<>(A<T>&)" would conform + friend int f(A<T>&); +private: + int x; +}; + +template <class T> int f(A<T>& a) { return a.x = 0; } +template int f(A<int>&); + +int main() +{ + A<int> a; + return f(a); +} +#endif + +#ifdef TEST_KWSYS_CXX_HAS_MEMBER_TEMPLATES +template <class U> +class A +{ +public: + U* ptr; + template <class V> U m(V* p) { return *ptr = *p; } +}; + +int main() +{ + A<int> a; + short s = 0; + return a.m(&s); +} +#endif + +#ifdef TEST_KWSYS_CXX_HAS_FULL_SPECIALIZATION +template <class T> struct A {}; +template <> struct A<int*> +{ + static int f() { return 0; } +}; +int main() { return A<int*>::f(); } +#endif + +#ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_REBIND +#include <memory> +template <class T, class Alloc> +void f(const T&, const Alloc&) +{ + typedef typename Alloc::template rebind<T>::other alloc_type; +}; +int main() +{ + f(0, std::allocator<char>()); + return 0; +} +#endif + #ifdef TEST_KWSYS_STAT_HAS_ST_MTIM #include <sys/types.h> #include <sys/stat.h> |