Skip to content

Instantly share code, notes, and snippets.

@Cryolite
Created August 4, 2012 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cryolite/3257985 to your computer and use it in GitHub Desktop.
Save Cryolite/3257985 to your computer and use it in GitHub Desktop.
// [conv.lval]/1
// A glvalue (3.10) of a non-function, non-array type T can be converted to
// a prvalue. If T is an incomplete type, a program that necessitates this
// conversion is ill-formed. ...
//
// [expr.cond]/3, /5 and /6
//
// Note: [class.conv.fct] does not require the type specified in
// conversion-type-id of conversion-function-id should be complete.
struct incomplete;
struct complete
{
operator incomplete();
};
template<typename T>
T &&declval();
template<typename T, typename = decltype(false ? declval<complete &>() : declval<T &>())>
constexpr bool test(int)
{
return true;
}
template<typename T>
constexpr bool test(void *)
{
return false;
}
int main()
{
static_assert(test<complete>(0), "");
static_assert(!test<incomplete>(0), "");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment