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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:35:08+00:00 2026-05-30T22:35:08+00:00

I have a debug class that I use in my code to print various

  • 0

I have a debug class that I use in my code to print various things. In this class I overload operator() to facilitate output. I have several operator()s to print vectors. When I added a template version, I came accross compile errors.

Here is the code:

  template<class Type1>
    inline debug&
    operator()(const std::string& name,
               typename std::vector<Type1>::const_iterator begin,
               typename std::vector<Type1>::const_iterator end)
    {    
      _stream << indent(internal) << "< " << name << " : [ ";
      std::copy(begin, end, std::ostream_iterator<Type1>(_stream, " "));
      _stream << "] >" << std::endl;

      return *this;
    }

And another vector print function I have:

  inline debug&
  operator()(const std::string& name,
             typename std::vector<uint32_t>::const_iterator begin,
             typename std::vector<uint32_t>::const_iterator end)
  {
    _stream << indent(internal) << "< " << name << " : [ " << std::hex;
    std::copy(begin, end, std::ostream_iterator<uint32_t>(_stream, " "));
    _stream << "] >" << std::endl;

    return *this;
  }

Where indent() does exactly what it says.

Here is the compile error:

../include/debug.hh:146:3: note: template<class Type1> relix::debug&    relix::debug::operator()(const string&, typename std::vector<_RealType>::const_iterator, typename std::vector<_RealType>::const_iterator)
../include/debug.hh:146:3: note:   template argument deduction/substitution failed:
assembler.cc:78:64: note:   couldn't deduce template parameter ‘Type1’

Here is assembler.cc:78:

  log(D_C(tl._tokens), tl._tokens.begin(), tl._tokens.end());

Where D_C() is a substitution preprocessor macro to extract the variable name and _tokens is a std::vector of token, where token has an overloaded operator<<().

  • 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-30T22:35:10+00:00Added an answer on May 30, 2026 at 10:35 pm

    The problem is with just the template:

    template<class Type1>
    inline debug&
    operator()(const std::string& name,
               typename std::vector<Type1>::const_iterator begin,
               typename std::vector<Type1>::const_iterator end)
    {    
    // ...
    

    The problem here is that Type1 cannot be deduced by the compiler. Consider what would be needed to actually deduce the type: The compiler would have to instantiate std::vector with all possible types, including any potential instantiation of std::vector to determine whether the argument to the function is a match.

    The simplest workaround is to drop vector from the explicit requirements in the signature and convert it to:

    template<class Iterator>
    inline debug&
    operator()(const std::string& name,
               Iterator begin,
               Iterator end)
    {    
    // ...
    

    Now the type can be trivially deduced, whatever the argument to the function is.

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

Sidebar

Related Questions

I have code like this: class Debug(object): ... @property def ThreadAwareLogger(self): if not self.logger_instance_for_current_thread:
I have a subroutine called debug I use in my code. It basically allows
I have an error log class that I use throughout all the files in
I have a java class and I need to debug it (put breakpoints and
I have to debug some error that is db related and have been continuously
I have various Debug.WriteLine messages, I tried to see those messages using export MONO_DEBUG_LEVEL=debug,
So I know now that the debug assemblies have been intentionally left out of
I have been helping someone debug some code where the error message was Day
I have a program that monitors debug messages and I have tried using a
I have a set of threaded classes that print different types of documents. The

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.