-3
#include <iostream>
#include <string>
#include <boost/algorithm/string.hpp>
using namespace std;

int main() {
  string city1, city2;
  cout << ("Please enter your citys name");
  cin >> city1;
  cout << ("Please enter your citys second name");
  cin >> city2;
  cout << city1 [0,1,2,3,4];
  cout << city2 [0,1,2,3,4];
  boost::to_upper(city1, city2);
  cout << city1,city2;
}

This is my code and for some reason boost::to_upper(city1, city2); gets the error: [cquery] no matching funtion for call 'to_upper'

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Bokkie
  • 11
  • 2
  • 4
    Isn't it `boost::algorithm::to_upper`? [Do not use `using namespace std`](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice). `cquery` is just language server. Any reason for using `boost` instead of C++ ``? – Quimby Sep 26 '20 at 09:49

1 Answers1

0

boost::algorithm::to_upper is declared as (from boost reference)

template<typename WritableRangeT> 
void to_upper(WritableRangeT & Input, const std::locale & Loc = std::locale());

so you can pass only one string to this function. Replacing

boost::to_upper(city1, city2);

with

boost::to_upper(city1);
boost::to_upper(city2);

makes the code compile and an example output is Please enter your citys namePlease enter your citys second nameosLONDON. It lacks newline characters and there is one more mistake - misunderstanding of comma operator. Generally comma is used to separate arguments or array elements but in lines

cout << city1 [0,1,2,3,4];
cout << city2 [0,1,2,3,4];
// ...
cout << city1,city2;

comma operator is used. Comma operators takes two operands and it's value is value of the right operand (e.g. after int x = (1, 2); variable x is equal to 2). Code above is equivalent to

cout << city1[4];
cout << city2[4];
// ...
cout << city1;
city2;

Finally, the corrected code is

#include <iostream>
#include <string>
#include <boost/algorithm/string.hpp>
using namespace std;

int main() {
  string city1, city2;
  cout << "Please enter your citys name" << std::endl;
  cin >> city1;
  cout << "Please enter your citys second name" << std::endl;
  cin >> city2;
  cout << city1 << std::endl;
  cout << city2  << std::endl;
  boost::to_upper(city1);
  boost::to_upper(city2);
  cout << city1 << std::endl << city2 << std::endl;
}
Antoni
  • 176
  • 2
  • 6