Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8107929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:56:00+00:00 2026-06-06T00:56:00+00:00

static_assert seems to be a very nice feature together with templates. However, I have

  • 0

static_assert seems to be a very nice feature together with templates.

However, I have trouble finding functions in the standard library for doing various tests at compile time.

For example, I am looking for a function to check whether a type is a subtype of another one. boost::is_base_of does the job, however, is a comparable function in std, so I do not need to rely on boost.

Basically, is there a good source for a list of functions which can be used in static_assert and are contained in the standard library of C++11?

When is static_assert executed? Can I put it anywhere in a template and it is evaluated for each template instanciation? Could it be used to constrain template parameters to be a specific subtype of a class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:56:01+00:00Added an answer on June 6, 2026 at 12:56 am

    Take a look at the final C++11 draft, section 20.7, particularly the <type_traits> header.

    What you are asking is: std::is_base_of<base, derived>::value;

    Regarding your question: static_assert can be evaluated whenever the compiler sees fit, but it will usually:

    • In a template: if the expression uses dependent names, in instatiation time; else, in definition time.
    • Out of template: in definition time.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a problem. I have seen many solutions, but no one seems to
I am not sure what I am doing wrong, have seen a lot of
I was under impression Visual C++ 10 had built-in static_assert . However when I
Could you give an example where static_assert(...) ('C++11') would solve the problem in hand
In my previous question I wanted to use static_assert to restrict a template parameter
I have the following code: template <typename T> LuaCall& operator>>(T) { BOOST_STATIC_ASSERT(sizeof(T) == 0);
Moles is an isolation framework created by Microsoft. A cool feature of Moles is
I would like to write tests for a C library, in C. I'd like
I'm trying to encrypt and decrypt data using RSA in C#. I have the
I have a class with a couple static arrays: an int[] with 17,720 elements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.