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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:26:13+00:00 2026-05-23T00:26:13+00:00

Is it possible to specialize an Iterator template parameter by its value_type ? I

  • 0

Is it possible to specialize an Iterator template parameter by its value_type?

I have a function with the following prototype.

template<typename InputIterator>
void f(InputIterator first, InputIterator last);

And I want to handle specially if InputIterator::value_type is SomeSpecificType.

  • 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-23T00:26:14+00:00Added an answer on May 23, 2026 at 12:26 am

    You can use some intermediate structs to get the partial template specialisation that you need. Something like this should do the trick

    template<typename T, typename V>
    struct f_impl
    {
      static void f( T first, T last ) {...}; //Default version
    };
    
    template<typename T>
    struct f_impl<T, SomeSpecificType>
    {
       static void f(T first,T last) {...}; //Specialisation
    };
    
    template<typename InputIterator> void f(InputIterator first, InputIterator last)
    {
      f_impl<
          InputIterator,
          typename std::iterator_traits<InputIterator>::value_type
      >::f(first,last);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a template function: template<typename T> void foo(const T& value) { bar(value); x
I want to specialize following member function: class foo { template<typename T> T get()
Say I have this: template<typename T, int X> class foo { public: void set(const
I have something like this in my code: template <typename T> struct A {
I have a template class which looks like the following: template <template <class TypeT>
I need a template like this, which work perfectly template <typename container> void mySuperTempalte
Say I have the following class: template<class T> struct A { static int value;
I have a simple class: template<size_t N, typename T> class Int { bool valid(size_t
I have a templated class with an templated member function template<class T> class A
I have an indexer function, and was attempting to specialize it for the standard

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.