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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:06:19+00:00 2026-06-18T08:06:19+00:00

In VS 2005 this code work fine, but in VS 2010 I have error

  • 0

In VS 2005 this code work fine, but in VS 2010 I have error
“could not deduce template argument for ‘T *’ from ‘std::queue<_Ty> *'”

I can’t understand what the problem is? Please, help me…

#include <string>
#include <queue>
using namespace std;
template<typename  T, typename  R, typename  P1>
int bindthis(T* obj, R (T::*func)(P1))
{
    return 1;
}
int _tmain(int argc, _TCHAR* argv[])
{
std::queue<std::wstring> queue_;

bindthis(&queue_, &std::queue<std::wstring>::push);
return 0;
}
  • 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-06-18T08:06:20+00:00Added an answer on June 18, 2026 at 8:06 am

    I’m not sure about Visual Studio, but in GCC this function compiles in C++03 mode but not in C++11 mode, so I imagine the problem is the same.

    The issue is that in C++11, an overload was added to std::queue::push, so the compiler doesn’t know which overload to pick. There are two ways to fix this:

    1. Specify the template arguments explicitly:

      bindthis<std::queue<std::wstring>, void, const std::wstring&>(&queue_, &std::queue<std::wstring>::push);
      
    2. Cast the function pointer to the desired type void (std::queue<std::wstring>::*)(const std::wstring&), so that the correct overload is chosen:

      typedef void (std::queue<std::wstring>::*push_func_ptr)(const std::wstring&);
      bindthis(&queue_, static_cast<push_func_ptr>(&std::queue<std::wstring>::push));
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In VS 2005, I have some code that looks like this: ifs.open(foo); while (!ifs.eof())
I have a MS-Visual Studio 2005 workspace having all c code. This application(exe) allocates
When I compile this code in Visual Studio 2005: template <class T> class CFooVector
When I ran as is, it works perfectly fine but putting this exact code
this is some code that SDL requires in visual studios 2005 in order for
This SQL Server 2005 T-SQL code: DECLARE @Test1 varchar; SET @Test1 = 'dog'; DECLARE
I have started writing a Macro in Visual Studio 2005 like this: Public Sub
I have a table called 'Audit' in SQL Server 2005 like this: Name |
I am using visual studio 2005 for c++ this summer, but I am still
I have a SQL Server 2005 output like this: Date | Result | Sum

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.