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 6991367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:29:28+00:00 2026-05-27T19:29:28+00:00

C++ is considered statically typed. I understand that. I don’t understand how that applies

  • 0

C++ is considered statically typed. I understand that.

I don’t understand how that applies to templates.

Here is a simple example of a type that cannot be determined at compile time:

template <typename... t>
struct foo {
  using type = typename foo<t..., t...>::type;
};

foo<int>::type x; // type of x cannot be determined without running meta-program

I presume there are cases where it’s impossible to detect type errors without solving the halting problem.

So my question is, why aren’t templates considered dynamically typed?

  • 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-05-27T19:29:29+00:00Added an answer on May 27, 2026 at 7:29 pm

    Static/dynamic typing typically refers to the behavior at runtime of the final compiled program, not of the meta-program. Since foo<int>::type is resolved by the time you reach runtime of the final compiled program, it’s considered statically typed.

    As for the template metaprogram, one could consider it to be using duck typing, which is a kind of dynamic typing. Note, however, that there are still static types (in pre-C++11) – the number of template arguments on a template can be considered a meta-type for a meta-function that produces a concrete type (which is a value as far as the meta-program is concerned).

    By comparison, in Haskell, they have a concept of a hierarchy of types. You have typical types – things like functions, integers, etc. Then you have ‘kinds’, which describe types and meta-functions on types. For example, the Haskell kind * -> * -> * could refer to a mapping of keys to values, much like a template<typename Key, typename Value> class Map in C++. Any determination on whether the language is statically or dynamically typed then would have to refer to which level of the hierarchy you’re referring to. Historically, C++ templates were never really thought of as meta-programs when they were first designed, so this kind of terminology isn’t as widely used in C++, but the same concepts can still be applied.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I considered the following experinment: simple C program, that only return 0, but linked
I have assembly A that depends (statically) on type T (reference type, a class)
Are modal windows/dialogs considered a good practice for websites? One of the things that
It's widely considered that the best reason to validate one's HTML is to ensure
Is type checking considered bad practice even if you are checking against an interface?
I come from a statically/strongly typed language background (java), and I recently started to
What OOP principles, if any, don't apply or apply differently in a dynamically typed
I don't understand why the ABI is important context of developing user-space applications. Is
I just considered using the new TDictionary type. But On QualityCentral I read about
Would it be considered bad practice to have a viewmodel that has a property

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.