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

  • Home
  • SEARCH
  • 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 8736143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:14:16+00:00 2026-06-13T10:14:16+00:00

The following code snippet work with Visual Studio 2008 but not with Visual Studio

  • 0

The following code snippet work with Visual Studio 2008 but not with Visual Studio 2010.

template <typename TKey>
struct MyStruct
{
    typedef std::map<TKey, int>  Keys;

    MyStruct()
    {
    }

    void set(TKey& key)
    {
#if 1
        // This works with VS 2008 but not with 2010
        keys_.insert(typename Keys::value_type(key, 1));
#else
        // This works with VS 2008 and VS 2010
        keys_.insert(std::pair<TKey, int>(key, 1));
#endif
    };

private:
    Keys keys_;
};

Usage

typedef std::tr1::tuple<int, int> MyValueType;
MyStruct<MyValueType> a;
MyValueType x;
a.set(x);

I get following error:

1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\tuple(127):
error C2440: ‘initializing’ : cannot convert from ‘const MyValueType’
to ‘int’ 1> No user-defined-conversion operator available
that can perform this conversion, or the operator cannot be called 1>
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxtuple0(9) :
see reference to function template instantiation
‘std::tr1::_Cons_node<_Car,_Cdr>::_Cons_node<_Ty,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&>(_Farg0
&&,_Farg1,_Farg2,_Farg3,_Farg4,_Farg5,_Farg6,_Farg7,_Farg8,_Farg9)’
being compiled 1> with 1> [ 1>
_Car=int, 1> _Cdr=std::tr1::_Cons_node::_Type>,
1> _Ty=MyValueType, 1> _Farg0=MyValueType,
1> _Farg1=std::tr1::_Nil &, 1>
_Farg2=std::tr1::_Nil &, 1> _Farg3=std::tr1::_Nil &, 1> _Farg4=std::tr1::_Nil &, 1> _Farg5=std::tr1::_Nil &, 1> _Farg6=std::tr1::_Nil &, 1> _Farg7=std::tr1::_Nil &, 1> _Farg8=std::tr1::_Nil &, 1> _Farg9=std::tr1::_Nil & 1> ] 1> C:\Program Files\Microsoft Visual Studio
10.0\VC\include\utility(145) : see reference to function template instantiation ‘std::tr1::tuple<_Arg0,_Arg1>::tuple>(_Farg0 &&)’ being compiled 1>
with 1> [ 1> _Arg0=int, 1>
_Arg1=int, 1> _Farg0=const std::tr1::tuple 1> ] 1> C:\Program Files\Microsoft Visual Studio
10.0\VC\include\utility(142) : while compiling class template member function ‘std::_Pair_base<_Ty1,_Ty2>::_Pair_base(const
std::tr1::tuple<_Arg0,_Arg1> &&,int &&)’ 1> with 1>
[ 1> _Ty1=const MyValueType, 1> _Ty2=int, 1>
_Arg0=int, 1> _Arg1=int 1> ] 1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\utility(174)
: see reference to class template instantiation
‘std::_Pair_base<_Ty1,_Ty2>’ being compiled 1> with 1>
[ 1> _Ty1=const MyValueType, 1> _Ty2=int 1>
] 1>
D:\Projekte\demo\Demo.cpp(40)
: see reference to class template instantiation ‘std::pair<_Ty1,_Ty2>’
being compiled 1> with 1> [ 1>
_Ty1=const MyValueType, 1> _Ty2=int 1> ] 1> D:\Projekte\demo\Demo.cpp(39)
: while compiling class template member function ‘void
MyStruct::set(TKey &)’ 1> with 1> [ 1>
TKey=MyValueType 1> ] 1>
D:\Projekte\demo\Demo.cpp(92)
: see reference to class template instantiation ‘MyStruct’ being
compiled 1> with 1> [ 1>
TKey=MyValueType 1> ] 1>C:\Program Files\Microsoft Visual
Studio 10.0\VC\include\tuple(127): error C2439:
‘std::tr1::_Cons_node<_Car,_Cdr>::_Value’ : member could not be
initialized 1> with 1> [ 1> _Car=int,
1>
_Cdr=std::tr1::_Cons_node::_Type>
1> ] 1> C:\Program Files\Microsoft Visual Studio
10.0\VC\include\tuple(170) : see declaration of ‘std::tr1::_Cons_node<_Car,_Cdr>::_Value’ 1> with 1>
[ 1> _Car=int, 1>
_Cdr=std::tr1::_Cons_node::_Type>
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

If a replace typedef std::tr1::tuple MyValueType with typedef int MyValueType it works.

Thank you in advance.

  • 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-13T10:14:17+00:00Added an answer on June 13, 2026 at 10:14 am

    I think this is an error that related to bad implementation of move semantic in MSVC 2010 since you can successfully compile this code:

    typename Keys::value_type v( key, 1 );
    keys_.insert(v);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why does following code snippet doesn't work? It doesn't gives any error, but also
The following code snippet in a Django template (v 1.1) doesn't work. {{ item.vendors.all.0
This following code snippet works fine using jQuery1.2.3, but it doesn’t work with latest
Hey guys, the following snippet of jQuery code seems to work fine in Google
Will the following code snippet of a synchronized ArrayList work in a multi-threaded environment?
I'm working on a visual studio 2008 add-in that will generate data-access code by
Consider the following code snippet about Twitter API. data.followers_count didn't work if placed in
I want your help with VB 2010 (Visual Studio 2010). Here is the code
The following code snippet works for me: class Foo { public: template <class T>
The following code snippet is returning an error in firebug: Parameter is not an

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.