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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:25:48+00:00 2026-05-29T09:25:48+00:00

Good day everybody! Having the following code: template<typename T, typename OutStream = std::ostream> struct

  • 0

Good day everybody!

Having the following code:

template<typename T, typename OutStream = std::ostream>
struct print
{
    OutStream &operator()(T const &toPrint, OutStream &outStream = std::cout) const
    {
        outStream << toPrint;
        return outStream;
    }
};

template<typename T, typename Index = unsigned int, typename CharType = char, typename OutStream = std::ostream>
struct print<T *, Index>
{
    print(CharType delimiter = ' '): delimiter_(delimiter) {}
    OutStream &operator()(T const *toPrint, Index startIndex, Index finishIndex, OutStream &outStream = std::cout) const
    {
        for (Index i(startIndex) ; i < finishIndex ; ++i)
            outStream << toPrint[i] << delimiter_;
        return outStream;
    }
protected:
    CharType delimiter_;
};

Compiler: MSVCPP10

Compiler Output:

1>main.cpp(31): error C2764: 'CharType' : template parameter not used or deducible in partial specialization 'print<T*,Index>'
1>main.cpp(31): error C2764: 'OutStream' : template parameter not used or deducible in partial specialization 'print<T*,Index>'
1>main.cpp(31): error C2756: 'print<T*,Index>' : default arguments not allowed on a partial specialization

I’m stuck. Help me to finish partial specialization.

Thanks!

  • 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-29T09:25:49+00:00Added an answer on May 29, 2026 at 9:25 am

    I assume this is what you mean: (This may be incorrect code, I’m only trying to translate what you wrote)

    template<typename T> struct print<T*, unsigned int> {
      typedef unsigned int Index;
      typedef std::ostream OutStream;
      typedef char CharType;
      print(CharType delimiter = ' '): delimiter_(delimiter) {}
      OutStream &operator()(T const *toPrint, Index startIndex, Index finishIndex, OutStream &outStream = std::cout) const {
        for (Index i(startIndex) ; i < finishIndex ; ++i)
          outStream << toPrint[i] << delimiter_;
        return outStream;
      }
    protected:
      CharType delimiter_;
    };
    

    The compiler explains what went wrong:

    default arguments not allowed on a partial specialization

    Meaning things like typename Index = unsigned int can only appear in the non-specialized template.

    template parameter not used or deducible in partial specialization

    Meaning you must use all the parameters in this part: struct print<HERE>

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

Sidebar

Related Questions

Good day, I'm having a problem with asp.net 2.0 viewstate. Basically, I want to
Good day, I am having an issue trying to get the Text on a
Good day everybody. I've doing a bit of training at working with Flex and
Good day code knights, I have a tricky problem that I cannot see a
Good day to all. I have the following setup: A page with html, js,
Good day! I've the following link: <%: Url.Action(MVC.Areas.Manage.Feedback.Index()) %> And it is generated as
Good day! I encountered the following error upon running my JSP program. java.lang.IllegalStateException: PWC3991:
Good day all; Firstly, either a process or pseudo code is hopefully sufficient to
Good day all I wrote the following method: private void RegisterEvent(object targetObject, string eventName,
Good day, We just converted our web application .NET 1.1 to .NET 2.0. We

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.