Skip to content

Commit 161cf73

Browse files
committed
fix: make example router move-only
fix #956
1 parent e618e69 commit 161cf73

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

example/router/detail/router.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class router_base
3939

4040
virtual ~router_base();
4141

42+
router_base(router_base const&) = delete;
43+
router_base& operator=(router_base const&) = delete;
44+
router_base(router_base&&) noexcept = default;
45+
router_base& operator=(router_base&&) noexcept = default;
46+
4247
void
4348
insert_impl(
4449
core::string_view s,

example/router/router.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class router
5454
/// Constructor
5555
router() = default;
5656

57+
router(router const&) = delete;
58+
router& operator=(router const&) = delete;
59+
router(router&&) noexcept = default;
60+
router& operator=(router&&) noexcept = default;
61+
5762
/** Route the specified URL path to a resource
5863
5964
@param path A url path with dynamic segments
@@ -88,4 +93,3 @@ class router
8893
#include "impl/router.hpp"
8994

9095
#endif
91-

test/unit/example/router/router.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,20 @@
1616

1717
#include "test_suite.hpp"
1818

19+
#include <type_traits>
20+
1921
namespace boost {
2022
namespace urls {
2123

24+
static_assert(!std::is_copy_constructible<router<int>>::value,
25+
"router should be move-only");
26+
static_assert(!std::is_copy_assignable<router<int>>::value,
27+
"router should be move-only");
28+
static_assert(std::is_move_constructible<router<int>>::value,
29+
"router should support moves");
30+
static_assert(std::is_move_assignable<router<int>>::value,
31+
"router should support moves");
32+
2233
struct router_test
2334
{
2435
static

0 commit comments

Comments
 (0)