|
| 1 | +// Copyright (c) 2026 Priyanshi Sharma |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: BSL-1.0 |
| 4 | +// Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5 | +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | + |
| 7 | +#include <hpx/config.hpp> |
| 8 | +#include <hpx/modules/serialization.hpp> |
| 9 | +#include <hpx/modules/testing.hpp> |
| 10 | + |
| 11 | +#include <string> |
| 12 | + |
| 13 | +namespace app { |
| 14 | + struct compute_server |
| 15 | + { |
| 16 | + static int compute(double x, double y) |
| 17 | + { |
| 18 | + return (int) (x + y); |
| 19 | + } |
| 20 | + static void broadcast(int n) noexcept |
| 21 | + { |
| 22 | + (void) n; |
| 23 | + } |
| 24 | + }; |
| 25 | +} // namespace app |
| 26 | + |
| 27 | +namespace app::nested { |
| 28 | + struct rpc_server |
| 29 | + { |
| 30 | + static double transform(float x, int n) |
| 31 | + { |
| 32 | + return x * n; |
| 33 | + } |
| 34 | + }; |
| 35 | +} // namespace app::nested |
| 36 | + |
| 37 | +namespace outer::inner { |
| 38 | + struct helper_server |
| 39 | + { |
| 40 | + static int process(int x) noexcept |
| 41 | + { |
| 42 | + return x * 2; |
| 43 | + } |
| 44 | + }; |
| 45 | +} // namespace outer::inner |
| 46 | + |
| 47 | +int main() |
| 48 | +{ |
| 49 | + using hpx::serialization::detail::scope_builder; |
| 50 | + |
| 51 | + // Static member function in simple namespace |
| 52 | + { |
| 53 | + constexpr auto name = |
| 54 | + scope_builder<^^app::compute_server::compute>::value; |
| 55 | + HPX_TEST_EQ(std::string(name.data, name.size), |
| 56 | + std::string("app::compute_server::compute")); |
| 57 | + } |
| 58 | + |
| 59 | + // Void return noexcept static member function |
| 60 | + { |
| 61 | + constexpr auto name = |
| 62 | + scope_builder<^^app::compute_server::broadcast>::value; |
| 63 | + HPX_TEST_EQ(std::string(name.data, name.size), |
| 64 | + std::string("app::compute_server::broadcast")); |
| 65 | + } |
| 66 | + |
| 67 | + // Static member function in nested inline namespace |
| 68 | + { |
| 69 | + constexpr auto name = |
| 70 | + scope_builder<^^app::nested::rpc_server::transform>::value; |
| 71 | + HPX_TEST_EQ(std::string(name.data, name.size), |
| 72 | + std::string("app::nested::rpc_server::transform")); |
| 73 | + } |
| 74 | + |
| 75 | + // Static member function in traditional nested namespace |
| 76 | + { |
| 77 | + constexpr auto name = |
| 78 | + scope_builder<^^outer::inner::helper_server::process>::value; |
| 79 | + HPX_TEST_EQ(std::string(name.data, name.size), |
| 80 | + std::string("outer::inner::helper_server::process")); |
| 81 | + } |
| 82 | + |
| 83 | + return hpx::util::report_errors(); |
| 84 | +} |
0 commit comments