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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:17:05+00:00 2026-06-05T23:17:05+00:00

The Problem Consider the following vectors: std::vector<std::string> extensions; extensions.push_back(.cpp); extensions.push_back(.CPP); extensions.push_back(.h); extensions.push_back(.H); std::vector<std::string> caselessUniqueExtensions;

  • 0

The Problem

Consider the following vectors:

std::vector<std::string> extensions;

extensions.push_back(".cpp");
extensions.push_back(".CPP");
extensions.push_back(".h");
extensions.push_back(".H");

std::vector<std::string> caselessUniqueExtensions;

Copy the contents of extensions into caselessUniqueExtensions, but discard all unique extensions, ignoring case. (I.e. the result should have two elements – one of either .cpp or .CPP, and one of either .h and .H.)

The Question

There are obviously many ways to do this, some more effecient than others, and some more readable than others. One such way I thought may work is the following:

#include <boost/algorithm/string/compare.hpp>

...

std::unique_copy(
  extensions.begin(), extensions.end(),
  caselessUniqueExts.begin(),
  boost::is_iequal());

However, it fails to compile using MSVS2010:

1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(626): error C2440: 'type cast' : cannot convert from 'unsigned char' to 'std::basic_string<_Elem,_Traits,_Ax>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          No constructor could take the source type, or constructor overload resolution was ambiguous
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(2211) : see reference to function template instantiation '_Elem std::_Maklocchr<_Elem>(char,_Elem *,const std::_Locinfo::_Cvtvec &)' being compiled
1>          with
1>          [
1>              _Elem=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(2210) : while compiling class template member function 'std::basic_string<_Elem,_Traits,_Ax> std::ctype<std::basic_string<_Elem,_Traits,_Ax>>::do_widen(char) const'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\locale(261) : see reference to class template instantiation 'std::ctype<_Elem>' being compiled
1>          with
1>          [
1>              _Elem=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\locale(259) : see reference to function template instantiation '_Elem std::toupper<T1>(_Elem,const std::locale &)' being compiled
1>          with
1>          [
1>              _Elem=std::basic_string<char,std::char_traits<char>,std::allocator<char>>,
1>              T1=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(2042) : see reference to function template instantiation 'bool boost::algorithm::is_iequal::operator ()<std::basic_string<_Elem,_Traits,_Ax>,std::basic_string<_Elem,_Traits,_Ax>>(const T1 &,const T2 &) const' being compiled
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>,
1>              T1=std::basic_string<char,std::char_traits<char>,std::allocator<char>>,
1>              T2=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(2070) : see reference to function template instantiation '_OutIt std::_Unique_copy<_InIt,_OutIt,_Pr>(_FwdIt,_FwdIt,_OutIt,_Pr,std::forward_iterator_tag)' being compiled
1>          with
1>          [
1>              _OutIt=std::_Vector_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>,
1>              _InIt=std::basic_string<char,std::char_traits<char>,std::allocator<char>> *,
1>              _Pr=boost::algorithm::is_iequal,
1>              _FwdIt=std::basic_string<char,std::char_traits<char>,std::allocator<char>> *
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(2094) : see reference to function template instantiation '_OutIt std::_Unique_copy1<std::basic_string<_Elem,_Traits,_Ax>*,_OutIt,_Pr>(_InIt,_InIt,_OutIt,_Pr,std::tr1::true_type)' being compiled
1>          with
1>          [
1>              _OutIt=std::_Vector_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>,
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>,
1>              _Pr=boost::algorithm::is_iequal,
1>              _InIt=std::basic_string<char,std::char_traits<char>,std::allocator<char>> *
1>          ]
1>          c:\users\stv04463\documents\visual studio 2010\projects\pgp sandbox\pgp sandbox\main.cpp(64) : see reference to function template instantiation '_OutIt std::unique_copy<std::_Vector_iterator<_Myvec>,std::_Vector_iterator<_Myvec>,boost::algorithm::is_iequal>(_InIt,_InIt,_OutIt,_Pr)' being compiled
1>          with
1>          [
1>              _OutIt=std::_Vector_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>,
1>              _Myvec=std::_Vector_val<std::string,std::allocator<std::string>>,
1>              _InIt=std::_Vector_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>,
1>              _Pr=boost::algorithm::is_iequal
1>          ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(593): error C2440: 'type cast' : cannot convert from 'std::basic_string<_Elem,_Traits,_Ax>' to 'unsigned char'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(2229) : see reference to function template instantiation 'char std::_Maklocbyte<std::basic_string<_Elem,_Traits,_Ax>>(std::basic_string<_Elem,_Traits,_Ax>,const std::_Locinfo::_Cvtvec &)' being compiled
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Ax=std::allocator<char>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(2225) : while compiling class template member function 'char std::ctype<_Elem>::_Donarrow(_Elem,char) const'
1>          with
1>          [
1>              _Elem=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1>          ]

Am I missing some basic understanding here, or should it not be possible to combine std::unique_copy with boost::is_iequal?

I am aware of the alternatives – I’d like to know why I’m getting this compiler error.

  • 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-05T23:17:06+00:00Added an answer on June 5, 2026 at 11:17 pm

    The boost::is_iequal predicate is meant to be used on single characters, not on an entire string like you’re doing.

    Unfortunately the Boost String Algorithms documentation is not the best, but you can see this specified here: “Defines element comparison predicates”, where “element” refers to the string characters.

    Internally, boost::is_iequal calls std::toupper on its arguments, and this can only work on characters.

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

Sidebar

Related Questions

I have the following problem. Consider the classes class face { virtual std::vector<ptr>& get_vertices(void)
Please consider the following example: #include <string> #include <vector> using std::string; using std::vector; template
Consider the following code, compiled with g++ problem.cpp -o problem : #include <vector> using
Consider the following problem: A multi-line string $junk contains some lines which are encoded
Please consider the following code: vector<int> myVector; myVector.push_back(10); myVector.erase(myVector.end()); This code compiles and runs
Consider the following class member: std::vector<sim_mob::Lane *> IncomingLanes_; the above container shall store the
Consider the following problem: given a list of length three of tuples (String,Int), is
Propose to consider the following problem. Suppose we have some composite object. Are there
This problem is only in IE. Consider the following HTML: <html> <body> <div style='position:absolute;left:1em;right:1em;top:1em;bottom:1em;overflow:auto;>
Consider the following code. #include <stdio.h> #include <vector> #include <iostream> struct XYZ { int

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.