__is_convertible_to is "supported by the compiler"
Compiler Support for Type Traits (C++/CLI and C++/CX) | Microsoft Learn
#include <stdio.h>
struct S {};
struct T : public S {};
struct myview
{
myview(const std::wstring& str) {}
};
void test_is_convertible_to() {
//S * s = new S;
//T * t = new T;
//s = t;
__is_convertible_to(std::wstring, myview) == true ?
printf("true\n") : printf("false\n");
__is_convertible_to(T, S) == true ?
printf("true\n") : printf("false\n");
}
int main()
{
test_is_convertible_to();
}
true
true
#include <stdio.h>
struct myview
{
myview(/*const*/ std::wstring& str) {}
};
void test_is_convertible_to() {
__is_convertible_to(std::wstring, myview) == true ?
printf("true\n") : printf("false\n");
}
int main()
{
test_is_convertible_to();
}
false
#include <stdio.h>
struct myview
{
//myview(const std::wstring& str) {}
};
void test_is_convertible_to() {
__is_convertible_to(std::wstring, myview) == true ?
printf("true\n") : printf("false\n");
}
int main()
{
test_is_convertible_to();
}
false