2121#endif // defined(_MSC_VER) && !defined(__clang__)
2222#include " utils.h"
2323
24- namespace {
25-
26- namespace spec {
24+ namespace proxy_invocation_tests_details {
2725
2826template <class ... Os>
2927struct MovableCallable : pro::facade_builder
@@ -113,8 +111,6 @@ struct SharedStringable : pro::facade_builder
113111 ::add_direct_convention<FreeGetWeak<SharedStringable>, pro::proxy<Weak<SharedStringable>>() const &>
114112 ::build {};
115113
116- } // namespace spec
117-
118114template <class F , bool NE, class ... Args>
119115concept CallableFacade =
120116 requires (pro::proxy<F> p, Args... args) {
@@ -123,16 +119,18 @@ concept CallableFacade =
123119};
124120
125121// Static assertions for facade Callable
126- static_assert (!CallableFacade<spec:: Callable<int (double )>, false , std::nullptr_t >); // Wrong arguments
127- static_assert (CallableFacade<spec:: Callable<int (double )>, false , float >); // Invoking without specifying a dispatch
128- static_assert (CallableFacade<spec:: Callable<int (double ), void (int ) noexcept >, true , int >); // Invoking noexcept overloads
129- static_assert (CallableFacade<spec:: Callable<int (double ), void (int ) noexcept >, false , double >); // Invoking overloads that may throw
122+ static_assert (!CallableFacade<Callable<int (double )>, false , std::nullptr_t >); // Wrong arguments
123+ static_assert (CallableFacade<Callable<int (double )>, false , float >); // Invoking without specifying a dispatch
124+ static_assert (CallableFacade<Callable<int (double ), void (int ) noexcept >, true , int >); // Invoking noexcept overloads
125+ static_assert (CallableFacade<Callable<int (double ), void (int ) noexcept >, false , double >); // Invoking overloads that may throw
130126
131127template <class ... Args>
132128std::vector<std::type_index> GetTypeIndices ()
133129 { return {std::type_index{typeid (Args)}...}; }
134130
135- } // namespace
131+ } // namespace proxy_invocation_tests_details
132+
133+ namespace details = proxy_invocation_tests_details;
136134
137135TEST (ProxyInvocationTests, TestArgumentForwarding) {
138136 std::string arg1 = " My string" ;
@@ -146,7 +144,7 @@ TEST(ProxyInvocationTests, TestArgumentForwarding) {
146144 arg2_received = std::move (v);
147145 return expected_result;
148146 };
149- pro::proxy<spec ::Callable<int (std::string, std::vector<int >)>> p = &f;
147+ pro::proxy<details ::Callable<int (std::string, std::vector<int >)>> p = &f;
150148 int result = (*p)(arg1, std::move (arg2));
151149 ASSERT_TRUE (p.has_value ());
152150 ASSERT_EQ (arg1_received, arg1);
@@ -159,7 +157,7 @@ TEST(ProxyInvocationTests, TestThrow) {
159157 const char * expected_error_message = " My exception" ;
160158 auto f = [&] { throw std::runtime_error{ expected_error_message }; };
161159 bool exception_thrown = false ;
162- pro::proxy<spec ::Callable<void ()>> p = &f;
160+ pro::proxy<details ::Callable<void ()>> p = &f;
163161 try {
164162 (*p)();
165163 } catch (const std::runtime_error& e) {
@@ -172,7 +170,7 @@ TEST(ProxyInvocationTests, TestThrow) {
172170
173171TEST (ProxyInvocationTests, TestMultipleDispatches_Unique) {
174172 std::list<int > l = { 1 , 2 , 3 };
175- pro::proxy<spec ::Iterable<int >> p = &l;
173+ pro::proxy<details ::Iterable<int >> p = &l;
176174 ASSERT_EQ (Size (*p), 3 );
177175 int sum = 0 ;
178176 auto accumulate_sum = [&](int x) { sum += x; };
@@ -182,12 +180,12 @@ TEST(ProxyInvocationTests, TestMultipleDispatches_Unique) {
182180
183181TEST (ProxyInvocationTests, TestMultipleDispatches_Duplicated) {
184182 struct DuplicatedIterable : pro::facade_builder
185- ::add_convention<spec ::FreeForEach, void (std::function<void (int &)>)>
186- ::add_convention<spec ::FreeSize, std::size_t ()>
187- ::add_convention<spec ::FreeForEach, void (std::function<void (int &)>)>
183+ ::add_convention<details ::FreeForEach, void (std::function<void (int &)>)>
184+ ::add_convention<details ::FreeSize, std::size_t ()>
185+ ::add_convention<details ::FreeForEach, void (std::function<void (int &)>)>
188186 ::build {};
189187 static_assert (sizeof (pro::details::facade_traits<DuplicatedIterable>::meta) ==
190- sizeof (pro::details::facade_traits<spec ::Iterable<int >>::meta));
188+ sizeof (pro::details::facade_traits<details ::Iterable<int >>::meta));
191189 std::list<int > l = { 1 , 2 , 3 };
192190 pro::proxy<DuplicatedIterable> p = &l;
193191 ASSERT_EQ (Size (*p), 3 );
@@ -199,7 +197,7 @@ TEST(ProxyInvocationTests, TestMultipleDispatches_Duplicated) {
199197
200198TEST (ProxyInvocationTests, TestRecursiveDefinition) {
201199 std::list<int > l = { 1 , 2 , 3 };
202- pro::proxy<spec ::Container<int >> p = &l;
200+ pro::proxy<details ::Container<int >> p = &l;
203201 ASSERT_EQ (Size (*p), 3 );
204202 int sum = 0 ;
205203 auto accumulate_sum = [&](int x) { sum += x; };
@@ -218,45 +216,45 @@ TEST(ProxyInvocationTests, TestOverloadResolution) {
218216 ::build {};
219217 std::vector<std::type_index> side_effect;
220218 auto p = pro::make_proxy<OverloadedCallable>([&](auto &&... args)
221- { side_effect = GetTypeIndices<std::decay_t <decltype (args)>...>(); });
219+ { side_effect = details:: GetTypeIndices<std::decay_t <decltype (args)>...>(); });
222220 (*p)(123 );
223- ASSERT_EQ (side_effect, GetTypeIndices<int >());
221+ ASSERT_EQ (side_effect, details:: GetTypeIndices<int >());
224222 (*p)(1.23 );
225- ASSERT_EQ (side_effect, GetTypeIndices<double >());
223+ ASSERT_EQ (side_effect, details:: GetTypeIndices<double >());
226224 char foo[2 ];
227225 (*p)(foo);
228- ASSERT_EQ (side_effect, GetTypeIndices<char *>());
226+ ASSERT_EQ (side_effect, details:: GetTypeIndices<char *>());
229227 (*p)(" lalala" );
230- ASSERT_EQ (side_effect, GetTypeIndices<const char *>());
228+ ASSERT_EQ (side_effect, details:: GetTypeIndices<const char *>());
231229 (*p)(" lalala" , 0 );
232- ASSERT_EQ (side_effect, (GetTypeIndices<std::string, int >()));
230+ ASSERT_EQ (side_effect, (details:: GetTypeIndices<std::string, int >()));
233231 ASSERT_FALSE ((std::is_invocable_v<decltype (*p), std::vector<int >>));
234232}
235233
236234TEST (ProxyInvocationTests, TestNoexcept) {
237235 std::vector<std::type_index> side_effect;
238- auto p = pro::make_proxy<spec ::Callable<void (int ) noexcept , void (double )>>([&](auto &&... args) noexcept
239- { side_effect = GetTypeIndices<std::decay_t <decltype (args)>...>(); });
236+ auto p = pro::make_proxy<details ::Callable<void (int ) noexcept , void (double )>>([&](auto &&... args) noexcept
237+ { side_effect = details:: GetTypeIndices<std::decay_t <decltype (args)>...>(); });
240238 static_assert (noexcept ((*p)(123 )));
241239 (*p)(123 );
242- ASSERT_EQ (side_effect, GetTypeIndices<int >());
240+ ASSERT_EQ (side_effect, details:: GetTypeIndices<int >());
243241 static_assert (!noexcept ((*p)(1.23 )));
244242 (*p)(1.23 );
245- ASSERT_EQ (side_effect, GetTypeIndices<double >());
243+ ASSERT_EQ (side_effect, details:: GetTypeIndices<double >());
246244 ASSERT_FALSE ((std::is_invocable_v<decltype (*p), char *>));
247245}
248246
249247TEST (ProxyInvocationTests, TestFunctionPointer) {
250- struct TestFacade : spec ::Callable<std::vector<std::type_index>()> {};
251- pro::proxy<TestFacade> p{ &GetTypeIndices<int , double > };
248+ struct TestFacade : details ::Callable<std::vector<std::type_index>()> {};
249+ pro::proxy<TestFacade> p{ &details:: GetTypeIndices<int , double > };
252250 auto ret = (*p)();
253- ASSERT_EQ (ret, (GetTypeIndices<int , double >()));
251+ ASSERT_EQ (ret, (details:: GetTypeIndices<int , double >()));
254252}
255253
256254TEST (ProxyInvocationTests, TestMemberDispatchDefault) {
257255 std::vector<std::string> container1{ " hello" , " world" , " !" };
258256 std::list<std::string> container2{ " hello" , " world" };
259- pro::proxy<spec ::ResourceDictionary> p = &container1;
257+ pro::proxy<details ::ResourceDictionary> p = &container1;
260258 ASSERT_EQ (p->at (0 ), " hello" );
261259 p = &container2;
262260 {
@@ -274,13 +272,13 @@ TEST(ProxyInvocationTests, TestMemberDispatchDefault) {
274272TEST (ProxyInvocationTests, TestFreeDispatchDefault) {
275273 {
276274 int side_effect = 0 ;
277- auto p = pro::make_proxy<spec ::WeakCallable<void ()>>([&] { side_effect = 1 ; });
275+ auto p = pro::make_proxy<details ::WeakCallable<void ()>>([&] { side_effect = 1 ; });
278276 (*p)();
279277 ASSERT_EQ (side_effect, 1 );
280278 }
281279 {
282280 bool exception_thrown = false ;
283- auto p = pro::make_proxy<spec ::WeakCallable<void ()>>(123 );
281+ auto p = pro::make_proxy<details ::WeakCallable<void ()>>(123 );
284282 try {
285283 (*p)();
286284 } catch (const std::runtime_error& e) {
@@ -293,7 +291,7 @@ TEST(ProxyInvocationTests, TestFreeDispatchDefault) {
293291
294292TEST (ProxyInvocationTests, TestObserverDispatch) {
295293 int test_val = 123 ;
296- pro::proxy<spec ::SharedStringable> p{std::make_shared<int >(test_val)};
294+ pro::proxy<details ::SharedStringable> p{std::make_shared<int >(test_val)};
297295 auto weak = GetWeak (p);
298296 ASSERT_TRUE (weak.has_value ());
299297 {
0 commit comments