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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:23:53+00:00 2026-06-08T11:23:53+00:00

Visual Studio Enterprise 2010, sp1, on Windows 7 64bit. Boost 1.48.0. Here begins the

  • 0

Visual Studio Enterprise 2010, sp1, on Windows 7 64bit. Boost 1.48.0.

Here begins the relevant code. These bits are defined in a header.

//typedef struct {} empty_t;
//typedef std::pair<size_t, std::shared_ptr<char>> string_t; //Don't ask...
//typedef boost::variant<empty_t, long, double, some other PODs, string_t> variant_t;
//typedef std::map<unsigned short, variant_t> variant_map_t;

and this is in the body of a copy constructor:

std::for_each(std::begin(incoming.values_), std::end(incoming.values_), [&](variant_map_t::value_type value)
{
    // This guy is going to populate this::values_, doing the right thing -
    // copying by value native and POD types, or deep copying pointers.
    boost::apply_visitor(deep_copy_visitor(*this, value.first), value.second);
});

The error I’m finding is with the parameter list of the lambda. swap is being called, I think in the copy constructor of the pair, trying to assign first from the rvalue passed to the lambda to the parameter. The compiler thinks “value.first” is const when it’s being assigned to in the std::pair copy constructor. But clearly, the parameter is not const qualified, the mapped_type or key_type isn’t const qualified, the copy constructor isn’t a const method, and NONE OF THAT SHOULD MATTER ANYWAY.

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility(209) : see reference to function template instantiation 'void std::_Swap_adl<_Ty1>(_Ty &,_Ty &)' being compiled
          with
          [
              _Ty1=unsigned short,
              _Ty=unsigned short
          ]
          C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility(206) : while compiling class template member function 'void std::pair<_Ty1,_Ty2>::swap(std::pair<_Ty1,_Ty2> &)'
          with
          [
              _Ty1=const unsigned short,
              _Ty2=variant_t
          ]
          src\foo.cpp(506) : see reference to class template instantiation 'std::pair<_Ty1,_Ty2>' being compiled
          with
          [
              _Ty1=const unsigned short,
              _Ty2=variant_t
          ]

So somehow, the template parameter is getting const qualified, and for the life of me, I can’t figure out why.

I think something else is tripping up the compiler, but I’ve got nothing else to go off of. Earlier, before I gave my source code a good stir, trying to figure this out, I could switch this error message on and off; I had defined a boost::static_visitor derived class. No members, no methods, nothing. That was enough to cause this error in my copy constructor here. I can’t imagine how else to isolate what is ACTUALLY the offending line of code…

Does anyone think this is a compiler hiccup, and that some unmentioned change has this as a side effect?

  • 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-08T11:23:55+00:00Added an answer on June 8, 2026 at 11:23 am

    The value_type of std::map<K, V> is std::pair<K const, V>, because the keys are immutable. So, yes, value.first is const-qualified.

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

Sidebar

Related Questions

I have Visual Studio 2010 Ultimate on Windows 7 Enterprise running on a x86
Visual Studio 2010 C# code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using
I have Windows 7 64 bit Enterprise edition installed. Which version of Visual Studio
I have Visual Studio 2008 installed on a Windows 2008 Enterprise Server. I am
Visual Studio 2010, I was able to view xaml in designer. Now every xaml
Visual studio seems intent that my javascript code is bad, mostly because it has
Visual Studio 2010 offers a lot of comfortable tools for unit testing via its
Visual Studio - Determining Lines No Of Lines of code in a project -
While installing Visual Studio 2010 Service Pack 1, I am getting this error: Installation
We have a Visual Studio 2010 solution that has over 120 projects that reference

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.