Skip to content

Commit 810c85f

Browse files
committed
fix warnings
1 parent 5e01b13 commit 810c85f

10 files changed

Lines changed: 154 additions & 143 deletions

include/boost/openmethod/core.hpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ using virtual_types = boost::mp11::mp_transform<
196196

197197
template<typename T, class Policy>
198198
struct parameter_traits {
199-
static auto peek(const T& arg) {
199+
static auto peek(const T&) {
200200
return nullptr;
201201
}
202202

@@ -346,15 +346,15 @@ class virtual_ptr_impl {
346346
virtual_ptr_impl() = default;
347347

348348
explicit virtual_ptr_impl(std::nullptr_t)
349-
: obj(nullptr), vp(box_vptr<use_indirect_vptrs>(null_vptr)) {
349+
: vp(box_vptr<use_indirect_vptrs>(null_vptr)), obj(nullptr) {
350350
}
351351

352352
template<
353353
class Other,
354354
typename = std::enable_if_t<std::is_constructible_v<Class*, Other*>>>
355355
virtual_ptr_impl(Other& other)
356-
: obj(&other),
357-
vp(box_vptr<use_indirect_vptrs>(Policy::dynamic_vptr(other))) {
356+
: vp(box_vptr<use_indirect_vptrs>(Policy::dynamic_vptr(other))),
357+
obj(&other) {
358358
}
359359

360360
template<
@@ -363,8 +363,8 @@ class virtual_ptr_impl {
363363
Class*,
364364
decltype(std::declval<virtual_ptr<Other, Policy>>().get())>>>
365365
virtual_ptr_impl(Other* other)
366-
: obj(other),
367-
vp(box_vptr<use_indirect_vptrs>(Policy::dynamic_vptr(*other))) {
366+
: vp(box_vptr<use_indirect_vptrs>(Policy::dynamic_vptr(*other))),
367+
obj(other) {
368368
}
369369

370370
template<
@@ -373,7 +373,7 @@ class virtual_ptr_impl {
373373
Class*,
374374
decltype(std::declval<virtual_ptr<Other, Policy>>().get())>>>
375375
virtual_ptr_impl(const virtual_ptr<Other, Policy>& other)
376-
: obj(other.get()), vp(other.vp) {
376+
: vp(other.vp), obj(other.get()) {
377377
}
378378

379379
template<
@@ -382,7 +382,7 @@ class virtual_ptr_impl {
382382
Class*,
383383
decltype(std::declval<virtual_ptr<Other, Policy>>().get())>>>
384384
virtual_ptr_impl(virtual_ptr<Other, Policy>& other)
385-
: obj(other.get()), vp(other.vp) {
385+
: vp(other.vp), obj(other.get()) {
386386
// Why is this needed? Consider this conversion conversion from
387387
// smart to dumb pointer:
388388
// virtual_ptr<std::shared_ptr<const Node>> p = ...;
@@ -397,7 +397,7 @@ class virtual_ptr_impl {
397397
class Other,
398398
typename = std::enable_if_t<std::is_constructible_v<Class*, Other*>>>
399399
virtual_ptr_impl(Other& other, const vptr_type& vp)
400-
: obj(&other), vp(box_vptr<use_indirect_vptrs>(vp)) {
400+
: vp(box_vptr<use_indirect_vptrs>(vp)), obj(&other) {
401401
}
402402

403403
template<
@@ -515,7 +515,7 @@ class virtual_ptr_impl<
515515
}
516516

517517
explicit virtual_ptr_impl(std::nullptr_t)
518-
: obj(nullptr), vp(box_vptr<use_indirect_vptrs>(null_vptr)) {
518+
: vp(box_vptr<use_indirect_vptrs>(null_vptr)), obj(nullptr) {
519519
}
520520

521521
virtual_ptr_impl(const virtual_ptr_impl& other) = default;
@@ -526,8 +526,9 @@ class virtual_ptr_impl<
526526
same_smart_ptr<Class, Other, Policy> &&
527527
std::is_constructible_v<Class, const Other&>>>
528528
virtual_ptr_impl(const Other& other)
529-
: obj(other), vp(box_vptr<use_indirect_vptrs>(
530-
other ? Policy::dynamic_vptr(*other) : null_vptr)) {
529+
: vp(box_vptr<use_indirect_vptrs>(
530+
other ? Policy::dynamic_vptr(*other) : null_vptr)),
531+
obj(other) {
531532
}
532533

533534
template<
@@ -536,8 +537,9 @@ class virtual_ptr_impl<
536537
same_smart_ptr<Class, Other, Policy> &&
537538
std::is_constructible_v<Class, Other&>>>
538539
virtual_ptr_impl(Other& other)
539-
: obj(other), vp(box_vptr<use_indirect_vptrs>(
540-
other ? Policy::dynamic_vptr(*other) : null_vptr)) {
540+
: vp(box_vptr<use_indirect_vptrs>(
541+
other ? Policy::dynamic_vptr(*other) : null_vptr)),
542+
obj(other) {
541543
}
542544

543545
template<
@@ -546,9 +548,9 @@ class virtual_ptr_impl<
546548
same_smart_ptr<Class, Other, Policy> &&
547549
std::is_constructible_v<Class, Other&&>>>
548550
virtual_ptr_impl(Other&& other)
549-
: obj(std::move(other)),
550-
vp(box_vptr<use_indirect_vptrs>(
551-
other ? Policy::dynamic_vptr(*other) : null_vptr)) {
551+
: vp(box_vptr<use_indirect_vptrs>(
552+
other ? Policy::dynamic_vptr(*other) : null_vptr)),
553+
obj(std::move(other)) {
552554
}
553555

554556
template<
@@ -557,7 +559,7 @@ class virtual_ptr_impl<
557559
same_smart_ptr<Class, Other, Policy> &&
558560
std::is_constructible_v<Class, const Other&>>>
559561
virtual_ptr_impl(const virtual_ptr<Other, Policy>& other)
560-
: obj(other.obj), vp(other.vp) {
562+
: vp(other.vp), obj(other.obj) {
561563
}
562564

563565
template<
@@ -566,11 +568,11 @@ class virtual_ptr_impl<
566568
same_smart_ptr<Class, Other, Policy> &&
567569
std::is_constructible_v<Class, Other&>>>
568570
virtual_ptr_impl(virtual_ptr<Other, Policy>& other)
569-
: obj(other.obj), vp(other.vp) {
571+
: vp(other.vp), obj(other.obj) {
570572
}
571573

572574
virtual_ptr_impl(virtual_ptr_impl&& other)
573-
: obj(std::move(other.obj)), vp(other.vp) {
575+
: vp(other.vp), obj(std::move(other.obj)) {
574576
other.vp = box_vptr<use_indirect_vptrs>(null_vptr);
575577
}
576578

@@ -580,7 +582,7 @@ class virtual_ptr_impl<
580582
same_smart_ptr<Class, Other, Policy> &&
581583
std::is_constructible_v<Class, Other&&>>>
582584
virtual_ptr_impl(virtual_ptr<Other, Policy>&& other)
583-
: obj(std::move(other.obj)), vp(other.vp) {
585+
: vp(other.vp), obj(std::move(other.obj)) {
584586
other.vp = box_vptr<use_indirect_vptrs>(null_vptr);
585587
}
586588

@@ -665,7 +667,7 @@ class virtual_ptr_impl<
665667

666668
template<typename Arg>
667669
virtual_ptr_impl(Arg&& obj, decltype(vp) other_vp)
668-
: obj(std::forward<Arg>(obj)), vp(other_vp) {
670+
: vp(other_vp), obj(std::forward<Arg>(obj)) {
669671
}
670672

671673
template<class Other>

test/test_blackbox.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -326,19 +326,19 @@ BOOST_OPENMETHOD_OVERRIDE(
326326
return Types(DIAGONAL_DIAGONAL, MATRIX_MATRIX);
327327
}
328328

329-
BOOST_OPENMETHOD_OVERRIDE(times, (double a, const matrix& m), Types) {
329+
BOOST_OPENMETHOD_OVERRIDE(times, (double, const matrix&), Types) {
330330
return Types(SCALAR_MATRIX, NONE);
331331
}
332332

333-
BOOST_OPENMETHOD_OVERRIDE(times, (double a, const diagonal_matrix& m), Types) {
333+
BOOST_OPENMETHOD_OVERRIDE(times, (double, const diagonal_matrix&), Types) {
334334
return Types(SCALAR_DIAGONAL, SCALAR_MATRIX);
335335
}
336336

337-
BOOST_OPENMETHOD_OVERRIDE(times, (const diagonal_matrix& m, double a), Types) {
337+
BOOST_OPENMETHOD_OVERRIDE(times, (const diagonal_matrix&, double), Types) {
338338
return Types(DIAGONAL_SCALAR, MATRIX_SCALAR);
339339
}
340340

341-
BOOST_OPENMETHOD_OVERRIDE(times, (const matrix& m, double a), Types) {
341+
BOOST_OPENMETHOD_OVERRIDE(times, (const matrix&, double), Types) {
342342
return Types(MATRIX_SCALAR, NONE);
343343
}
344344

@@ -389,9 +389,10 @@ BOOST_OPENMETHOD_OVERRIDE(
389389
return Types(DIAGONAL_MATRIX, next(a, b).first);
390390
}
391391

392+
392393
BOOST_AUTO_TEST_CASE(ambiguity) {
393394
auto compiler = initialize<policy>();
394-
BOOST_TEST(compiler.report.ambiguous == 1);
395+
BOOST_TEST(compiler.report.ambiguous == 1u);
395396

396397
// N2216: in case of ambiguity, pick one.
397398
diagonal_matrix diag1, diag2;
@@ -436,7 +437,7 @@ BOOST_OPENMETHOD_OVERRIDE(
436437

437438
BOOST_AUTO_TEST_CASE(covariant_return_type) {
438439
auto compiler = initialize<policy>();
439-
BOOST_TEST(compiler.report.ambiguous == 0);
440+
BOOST_TEST(compiler.report.ambiguous == 0u);
440441

441442
// N2216: use covariant return types to resolve ambiguity.
442443
dense_matrix left, right;
@@ -462,7 +463,7 @@ struct BOOST_OPENMETHOD_NAME(poke);
462463
using poke =
463464
method<BOOST_OPENMETHOD_NAME(poke)(virtual_<Animal&>), std::string>;
464465

465-
auto poke_dog(Dog& dog) -> std::string {
466+
auto poke_dog(Dog&) -> std::string {
466467
return "bark";
467468
}
468469

@@ -573,7 +574,7 @@ class Dog : public animals::Animal {};
573574

574575
BOOST_OPENMETHOD_CLASSES(Dog, animals::Animal);
575576

576-
BOOST_OPENMETHOD_OVERRIDE(poke, (const Dog& dog), std::string) {
577+
BOOST_OPENMETHOD_OVERRIDE(poke, (const Dog&), std::string) {
577578
return "bark";
578579
}
579580

@@ -621,39 +622,39 @@ BOOST_AUTO_TEST_CASE(initialize_report) {
621622
method<meet_(virtual_<Animal&>, virtual_<Animal&>), void, policy>;
622623

623624
auto report = initialize<policy>().report;
624-
BOOST_TEST(report.not_implemented == 3);
625-
BOOST_TEST(report.ambiguous == 0);
625+
BOOST_TEST(report.not_implemented == 3u);
626+
BOOST_TEST(report.ambiguous == 0u);
626627
// 'meet' dispatch table is one cell, containing 'not_implemented'
627-
BOOST_TEST(report.cells == 1);
628+
BOOST_TEST(report.cells == 1u);
628629

629630
BOOST_OPENMETHOD_REGISTER(poke::override<fn<Animal>>);
630631
report = initialize<policy>().report;
631-
BOOST_TEST(report.not_implemented == 2);
632+
BOOST_TEST(report.not_implemented == 2u);
632633

633634
BOOST_OPENMETHOD_REGISTER(pet::override<fn<Cat>>);
634635
BOOST_OPENMETHOD_REGISTER(pet::override<fn<Dog>>);
635636
report = initialize<policy>().report;
636-
BOOST_TEST(report.not_implemented == 2);
637+
BOOST_TEST(report.not_implemented == 2u);
637638

638639
// create ambiguity
639640
BOOST_OPENMETHOD_REGISTER(meet::override<fn<Animal, Cat>>);
640641
BOOST_OPENMETHOD_REGISTER(meet::override<fn<Dog, Animal>>);
641642
report = initialize<policy>().report;
642-
BOOST_TEST(report.cells == 4);
643-
BOOST_TEST(report.ambiguous == 1);
643+
BOOST_TEST(report.cells == 4u);
644+
BOOST_TEST(report.ambiguous == 1u);
644645

645646
BOOST_OPENMETHOD_REGISTER(meet::override<fn<Cat, Cat>>);
646647
report = initialize<policy>().report;
647-
BOOST_TEST(report.cells == 6);
648-
BOOST_TEST(report.ambiguous == 1);
648+
BOOST_TEST(report.cells == 6u);
649+
BOOST_TEST(report.ambiguous == 1u);
649650

650651
// shadow ambiguity
651652
BOOST_OPENMETHOD_REGISTER(meet::override<fn<Dog, Dog>>);
652653
BOOST_OPENMETHOD_REGISTER(meet::override<fn<Dog, Cat>>);
653654
BOOST_OPENMETHOD_REGISTER(meet::override<fn<Cat, Dog>>);
654655
report = initialize<policy>().report;
655-
BOOST_TEST(report.cells == 9);
656-
BOOST_TEST(report.ambiguous == 0);
656+
BOOST_TEST(report.cells == 9u);
657+
BOOST_TEST(report.ambiguous == 0u);
657658
}
658659

659660
} // namespace report

0 commit comments

Comments
 (0)