C++ Logo

std-proposals

Advanced search

Re: is_complete type trait?

From: connor horman <chorman64_at_[hidden]>
Date: Thu, 11 Nov 2021 20:05:03 -0500
is_complete is a pure footgun. You can write it in pure C++ today, but
there are many questions about how it behaves, that can really only be
answered with "UB" or IFNDR. For example:

struct S;

constexpr bool A = std::is_complete_v<S>;
struct S{};
constexpr bool B = std::is_complete_v<S>; // What's the value of B here?

Or
// Foo.hpp
template<typename T> int break_the_world(){
    if constexpr(std::is_complete_v<T>)
        return 42;
    else
         return 1337;
}

// A.cpp
#include "Foo.hpp"
struct S;
void foo(){
    break_the_world<S>();
}

// B.cpp
#include "Foo.hpp"
struct S{};
void foo(){
    break_the_world<S>();
}


On Thu, 11 Nov 2021 at 18:51, Bjorn Reese via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Has there been any proposals to add a type trait to check if a type is
> complete?
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2021-11-11 19:05:18