File tree Expand file tree Collapse file tree
include/boost/http/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,6 +47,14 @@ class BOOST_HTTP_DECL
4747 std::shared_ptr<impl> impl_;
4848
4949public:
50+ /* * Default constructor.
51+
52+ Creates a flat_router in an empty state. The only valid
53+ operations on a default-constructed router are assignment
54+ and destruction.
55+ */
56+ flat_router () = default ;
57+
5058 flat_router (
5159 detail::router_base&&);
5260
Original file line number Diff line number Diff line change @@ -80,10 +80,31 @@ struct flat_router_test
8080 BOOST_TEST_EQ (*counter, 2 );
8181 }
8282
83+ void testDefaultConstruction ()
84+ {
85+ auto counter = std::make_shared<int >(0 );
86+ test_router r;
87+ r.all (" /" , [counter](params&) -> route_task
88+ {
89+ ++(*counter);
90+ co_return route_result{};
91+ });
92+
93+ flat_router fr1; // default construct
94+ flat_router fr2 (std::move (r));
95+ fr1 = fr2; // assign to default-constructed
96+
97+ params req;
98+ capy::test::run_blocking ()(fr1.dispatch (
99+ http::method::get, urls::url_view (" /" ), req));
100+ BOOST_TEST_EQ (*counter, 1 );
101+ }
102+
83103 void run ()
84104 {
85105 testCopyConstruction ();
86106 testCopyAssignment ();
107+ testDefaultConstruction ();
87108 }
88109};
89110
You can’t perform that action at this time.
0 commit comments