Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. type trait is_base_of compiles here but not there

type trait is_base_of compiles here but not there

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++asp-nethelp
3 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BernardIE5317
    wrote on last edited by
    #1

    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 the requires 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();
    

    }

    J 1 Reply Last reply
    0
    • B BernardIE5317

      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 the requires 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();
      

      }

      J Offline
      J Offline
      jeron1
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • J jeron1

        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

        B Offline
        B Offline
        BernardIE5317
        wrote on last edited by
        #3

        Thank You for your interest. Please see updated post. Kind Regards

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups