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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:12:16+00:00 2026-05-12T09:12:16+00:00

I keep receiving a C2664 conversion error in visual studio It tells me that

  • 0

I keep receiving a C2664 conversion error in visual studio

It tells me that it can’t convert parameter 1 from const std::string to std::string&. I tried adding/removing the const in the stringToWstring prototype and in the function itself and the error still comes up.

    wstring hexval = buff.substr(buff.find(L"hex(2):"));
    wstring h;
    wchar_t ch;

    typedef boost::tokenizer<boost::char_separator<wchar_t> > tokenizer;
    boost::char_separator<wchar_t> sep(L"//,");

    tokenizer tokens(hexval, sep);

    for(tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); tok_iter++)
    {
        ch = someFunction(*tok_iter); //error here
        h += ch;
    }



wstring stringToWstring(const string& s)
{
    wstring temp(s.length(), L'');
    copy(s.begin(), s.end(), temp.begin());
    return temp;
}

    wchar_t someFunction(const wstring &hex_val)
{

}

Any ideas?

EDIT:

I see that this is really confusing so I’m going to explain a bit more..

Originally, what I wanted was these lines inside the for loop

ch = someFunction(*tok_iter);
h += ch

I also expected *tok_iter to return a wstring but I was getting an error like: cannot convert parameter 1 from const std::string to const std::wstring&

Because of that, I assumed that somehow, *tok_iter is a const std::string thus, I created a stringToWstring function to do the conversion. To do this in the for loop

ch = someFunction(stringToWstring(*tok_iter));
h += ch

When I did that, I got:

Error   1   error C2664: 'std::_String_const_iterator<_Elem,_Traits,_Alloc>::_String_const_iterator(const std::_String_const_iterator<_Elem,_Traits,_Alloc> &)' : cannot convert parameter 1 from 'std::_String_const_iterator<_Elem,_Traits,_Alloc>' to 'const std::_String_const_iterator<_Elem,_Traits,_Alloc> &'    c:\program files\boost\boost_1_39\boost\tokenizer.hpp   63

I hope that’s clearer now.

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

    Looking at the edited question, your error is inside boost/tokenizer.hpp, not at the specified line.

    So my guess is that your tokenizer is wrong. Looking at http://www.boost.org/doc/libs/1_34_0/libs/tokenizer/tokenizer.htm it takes three template arguments, and the third one defaults to std::string. Since you want to use it on a std::wstring, I’d say you should create your tokenizer like this instead:

    tokenizer<boost::char_separator<wchar_t>, std::wstring::const_iterator, std::wstring>
    

    In general when debugging errors in template types, be sure to look in the Output pane, at the lines following the error. Visual Studio will tell you the types used in the templates there, allowing you to distinguish the first std::_String_const_iterator<_Elem,_Traits,_Alloc> in the error message from the second const std::_String_const_iterator<_Elem,_Traits,_Alloc> & (VC++ really isn’t very good at formatting this information, but it’s there)

    Most likely, one of them has char for _Elem and the other has wchar_t.

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

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.