Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / tests / Compiler_Features_24_Test.cpp
blob003b70fd525ba539829eb696dbfc634d6370a12c
1 /**
2 * This program checks if the compiler doesn't have a certain bug
3 * that we encountered when testing C++11 features
4 */
6 #include "test_config.h"
8 #include <type_traits>
9 #include <memory>
11 namespace FOO
13 template <typename T>
14 class o_r;
16 template <typename T>
17 struct o_t
19 using ref_type = o_r<T>;
21 class T_base {};
23 template<typename T,
24 typename = typename std::enable_if<
25 std::is_base_of<T_base, T>::value>::type, typename ...Args>
26 o_r<T> make_f(Args&& ...args);
28 template <typename T>
29 class o_r final
31 public:
32 template <typename _Tp1, typename, typename ...Args>
33 friend o_r<_Tp1> make_f(Args&& ...args);
34 protected:
35 using shared_ptr_type = std::shared_ptr<T>;
36 template<typename _Tp1, typename = typename
37 std::enable_if<std::is_convertible<_Tp1*, T*>::value>::type>
38 explicit o_r (_Tp1*)
39 : stub_ ()
41 private:
42 shared_ptr_type stub_;
45 template<typename T, typename, typename ...Args>
46 inline o_r<T> make_f(Args&& ...args)
48 return o_r<T> (new T (std::forward<Args> (args)...));
51 class A : public T_base
53 protected:
54 A () = default;
55 template <typename _Tp1, typename, typename ...Args>
56 friend o_r<_Tp1> make_f(Args&& ...args);
59 o_t<A>::ref_type create ()
61 return make_f<A>();
64 class B {};
67 int
68 run_main (int, ACE_TCHAR *[])
70 ACE_START_TEST (ACE_TEXT("Compiler_Features_24_Test"));
72 FOO::o_r<FOO::A> l = FOO::create();
74 FOO::o_r<FOO::A> l2 = FOO::make_f<FOO::A>();
75 // next line doesn't compile and shouldn't
76 //FOO::o_r<FOO::B> l3 = FOO::make_f<FOO::B>();
78 ACE_DEBUG ((LM_INFO,
79 ACE_TEXT ("Compiler Feature 24 Test does compile and run.\n")));
80 ACE_END_TEST;
82 return 0;