type trait is_base_of compiles here but not there
-
Greetings Kind Regards Each of the two uses of the type trait
is_base_of
compiles differently. One w/ error the other w/o. Any idea why the difference? It is documented as requiring a completed type I am not certain as to its meaning but the question remains why the difference? Thank You Kindly The precise error message wrt therequires
expression is: 1>D:\a\_work\1\s\binaries\x86ret\inc\type_traits(1152,28): error C2139: 'cDERIVED': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_base_of' hello_world.cpp(5): message : see declaration of 'cDERIVED' hello_world.cpp(7): message : see reference to variable template 'const bool is_base_of_v' being compiled hello_world.cpp(9,2): error C7602: 'cDERIVED::someClass': the associated constraints are not satisfied hello_world.cpp(8): message : see declaration of 'cDERIVED::someClass' hello_world.cpp(7,32): message : the constraint was not satisfied hello_world.cpp(9,22): error C2955: 'cDERIVED::someClass': use of class template requires template argument list hello_world.cpp(8): message : see declaration of 'cDERIVED::someClass' 1>Done building project "hello_world.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ========== Elapsed 00:02.511 ==========import std.core;
using namespace std;class cBASE {};
struct cDERIVED : public cBASE
{
template requires is_base_of_v // will not compile
class someClass {};
someClass someData;
constexpr bool TEST_is_base_of() { return is_base_of_v; } // will compile and return true
};int main()
{
cout << "Hello World\n";
cout << boolalpha;cDERIVED \_derived; cout << \_derived.TEST\_is\_base\_of();
}
-
Greetings Kind Regards Each of the two uses of the type trait
is_base_of
compiles differently. One w/ error the other w/o. Any idea why the difference? It is documented as requiring a completed type I am not certain as to its meaning but the question remains why the difference? Thank You Kindly The precise error message wrt therequires
expression is: 1>D:\a\_work\1\s\binaries\x86ret\inc\type_traits(1152,28): error C2139: 'cDERIVED': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_base_of' hello_world.cpp(5): message : see declaration of 'cDERIVED' hello_world.cpp(7): message : see reference to variable template 'const bool is_base_of_v' being compiled hello_world.cpp(9,2): error C7602: 'cDERIVED::someClass': the associated constraints are not satisfied hello_world.cpp(8): message : see declaration of 'cDERIVED::someClass' hello_world.cpp(7,32): message : the constraint was not satisfied hello_world.cpp(9,22): error C2955: 'cDERIVED::someClass': use of class template requires template argument list hello_world.cpp(8): message : see declaration of 'cDERIVED::someClass' 1>Done building project "hello_world.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ========== Elapsed 00:02.511 ==========import std.core;
using namespace std;class cBASE {};
struct cDERIVED : public cBASE
{
template requires is_base_of_v // will not compile
class someClass {};
someClass someData;
constexpr bool TEST_is_base_of() { return is_base_of_v; } // will compile and return true
};int main()
{
cout << "Hello World\n";
cout << boolalpha;cDERIVED \_derived; cout << \_derived.TEST\_is\_base\_of();
}
Could you post the exact error that you are seeing?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
-
Could you post the exact error that you are seeing?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
Thank You for your interest. Please see updated post. Kind Regards