Why doesn't make_pair<string, string>() call the copy contructor, when given const string&?

Both GCC and Clang refuse to compile this one: #include <string> #include <utility> using namespace std; int main() { const string s = "12345"; const string& r = s; auto p = std::make_pair<string, string>(r, r); } GCC says: error: cannot bind rvalue reference of type ‘std::__cxx11::basic_string<char>&&’ to lvalue of type ‘const std::string’ {aka ‘const std::__cxx11::basic_string<char>’}… Read More Why doesn't make_pair<string, string>() call the copy contructor, when given const string&?

Custom set comparison function in a template class

I was trying to figure out this exercise from a school exam. They implemented an abstract template Book class, and the assignment is to implement a bookshelf class. I tried to construct a set of book pointers with a custom comparator, but then I encounter a compilation error: In template: reference to type ‘const Book<std::basic_string<char>>’… Read More Custom set comparison function in a template class

cannot bind non-const lvalue reference of type 'int*&' to an rvalue of type 'int*'

I am aware that there are some questions similar to this one but I am a beginner in c++ and those examples were a bit difficult to comprehend for me. In my problem, I have a function called void selectNegatives(int*&,int&,int*&,int&). What this function does is it iterates over an input array, removes negative ints from… Read More cannot bind non-const lvalue reference of type 'int*&' to an rvalue of type 'int*'

This statement gives an error saying "Expression must be a modifiable lvalue"

I have declared a two dimensional character array matrix[][]. char matrix[3][3] = {{‘ ‘, ‘ ‘, ‘ ‘},{‘ ‘, ‘ ‘, ‘ ‘},{‘ ‘, ‘ ‘, ‘ ‘}}; In a function vacantCenter(), I am trying to return 1, if matrix[1][1] stores a whitespace, else 0 if it doesn’t. int vacantCenter() { int n; (matrix[1][1] ==… Read More This statement gives an error saying "Expression must be a modifiable lvalue"

Web-Scraping using R (I want to extract some table like data from a website)

I’m having some problems scraping data from a website. I do have not a lot of experience with web-scraping. My intended plan is to scrape some data using R from the following website: https://www.myfxbook.com/forex-broker-swaps More precisely, I want to extract the Forex Brokers Swap Comparison for all the available pairs. My idea so far: library(XML)… Read More Web-Scraping using R (I want to extract some table like data from a website)

Why is static_cast<Object&&> necessary in this function?

Trying to understand std::move, I found this answer to another question. Say I have this function Object&& move(Object&& arg) { return static_cast<Object&&>(arg); } What I think I understand: arg is an lvalue (value category). arg is of type "rvalue ref to Object". static_cast converts types. arg and the return type both being of type "rvalue… Read More Why is static_cast<Object&&> necessary in this function?

How can I iterate through object of objects data to fill angular table

I’m having a hard time trying to iterate data fetched from api through angular bootstrap table. From a first approach I was mapping the data to prsnl variable declared as prsnl: any and initialized in the function bellow: getAllPersnlValues(data) { return this.persnlService.getPersnl(data) .pipe( map((response) => response) ).subscribe((res) => {this.prsnl = res; console.log(‘prsnl’, this.prsnl)}); } In… Read More How can I iterate through object of objects data to fill angular table