[Boost-bugs] [Boost C++ Libraries] #12285: type_traits must assert type completeness for some traits

Subject: [Boost-bugs] [Boost C++ Libraries] #12285: type_traits must assert type completeness for some traits
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-06-18 10:25:00


#12285: type_traits must assert type completeness for some traits
------------------------------+-------------------------
 Reporter: apolukhin | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: type_traits
  Version: Boost 1.61.0 | Severity: Problem
 Keywords: |
------------------------------+-------------------------
 Without that check hard detectable errors are possible:

 {{{
 #include <boost/type_traits.hpp>

 struct foo;

 void kill_sanity() {
     (void)boost::is_constructible<foo, foo>::value;
 }

 struct foo{};

 int main() {
     static_assert(boost::is_constructible<foo, foo>::value, "foo must be
 constructible from foo"); // Ooops
 }
 }}}

 All the is_*constructible, is_base_of, is_convertible, is_destructible,
 is_*swappable, has_virtual_destructor traits must assert completeness.

 Solution could be to create an asserting structure (pseudocode):

 {{{
 template <class T>
 struct assert_complete {
     template <class U> yes_type test(mpl::int_<sizeof(U)>* = 0);
     template <class U> no_type test(...);

     static_assert(sizeof(test<T>(0)) == sizeof(yes_type), "T must be a
 complete type!");
 };
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12285>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC