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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:27:24+00:00 2026-05-23T14:27:24+00:00

Given a template function, that does not use the template parameter for input directly.

  • 0

Given a template function, that does not use the template parameter for input directly. How would C++ type inference work? For instance given

template<typename T>
void f(T::value_type){}

when (if at all) will type inference work for this function?

Is there any other place except of template<typename T1,...>void f(T1,T2,...) where type inference might occur?

As always, quote the standard for extra credit.

  • 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-23T14:27:24+00:00Added an answer on May 23, 2026 at 2:27 pm

    I think here’s your answer:

    14.8.2.4 – Deducing template arguments from a type [temp.deduct.type]

    […]

    -3- […]

    In most cases, the types, templates, and non-type values that are used to compose P participate in template argument deduction. That is, they may be used to determine the value of a template argument, and the value so determined must be consistent with the values determined elsewhere. In certain contexts, however, the value does not participate in type deduction, but instead uses the values of template arguments that were either deduced elsewhere or explicitly specified. If a template parameter is used only in nondeduced contexts and is not explicitly specified, template argument deduction fails.

    -4- The nondeduced contexts are:

    • The nested-name-specifier of a type that was specified using a qualified-id.

    • A type that is a template-id in which one or more of the template-arguments is an expression that references a template-parameter.

    When a type name is specified in a way that includes a nondeduced context, all of the types that comprise that type name are also nondeduced. However, a compound type can include both deduced and nondeduced types. [Example: If a type is specified as A<T>::B<T2>, both T and T2 are nondeduced. Likewise, if a type is specified as A<I+J>::X<T>, I, J, and T are nondeduced. If a type is specified as void f(A<T>::B, A<T>), the T in A<T>::B is nondeduced but the T in A<T> is deduced. ]

    Your T::value_type is a qualified-id of a type, so types in its nested-name-specifier are nondeduced and must be specified explicitly.

    Edit: this information is from ISO/IEC 14882:1998.

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

Sidebar

Related Questions

In C++, I have a certain template function that, on a given condition, calls
Given a class with a member template function like this one: template <typename t>
C++0x thread library or Boost.thread define a non-member variadic template function that locks all
I have a smart pointer type, and would like to construct an object that
Given the following form: <form id=form name=form> <input name=name/> <input name=version/> <input name=template/> <textarea
How would I declare a semantic action that calls a free function that doesn't
I got trouble in creating special instance of member template function of non-template class.
I have a template member function with this signature: template<typename T> void sync(void (*work)(T*),
**I've gotten a few suggestions to make my function pure generic, which would work,
Given the following XML 'template': <Request module=CRM call=list_service_features id={ID}> <block name=auth> <a name=username format=text>{USERNAME}</a>

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.