File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -419,6 +419,7 @@ namespace utils {
419419 constexpr typename std::add_const<T>::type & as_const (T& t) noexcept
420420 {
421421 static_assert (!std::is_const<T>::value, " object is already const" );
422+ static_assert (!std::is_pointer<T>::value, " object is a pointer" );
422423 // NOLINTNEXTLINE(bugprone-return-const-ref-from-parameter) - potential false positive
423424 return t;
424425 }
Original file line number Diff line number Diff line change @@ -542,10 +542,9 @@ class TestUtils : public TestFixture {
542542 ASSERT (c.written );
543543 }
544544 {
545- C c;
546- C* cp = &c;
547- utils::as_const (cp)->f (); // (correctly) calls non-const version
548- ASSERT (c.written );
545+ int i;
546+ auto cr = utils::as_const (i); // TODO: does nothing and should not be allowed
547+ (void )cr;
549548 }
550549 }
551550
You can’t perform that action at this time.
0 commit comments