Created
August 4, 2012 14:13
-
-
Save Cryolite/3257985 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [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