You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
cpp2front makes the last usage of a variable be a std::move(variable). In the case the last usage of the variable is for reading a file using std::ifstream's ">> " operator, the generated cpp1 code doesn't compile and gives the following error (and about 10 screens of template errors):
error: no match for ‘operator>>’ (oper
and types are ‘std::ifstream’ {aka ‘std::basic_ifstream’} and ‘std::remove_reference
<std::__cxx11::basic_string&>::type’ {aka ‘std::__cxx11::basic_string’})
24 | read >> temp;
| ~~~~ ^~ ~~~~~
| | |
| | std::remove_reference<std::__cxx11::basic_string&>::t
ype {aka std::__cxx11::basic_string}
| std::ifstream {aka std::basic_ifstream}
To Reproduce
Steps to reproduce the behavior:
Sample code - distilled down to minimal essentials please
Additional context
When I add temp+=temp; (just for a dummy last use of it) as the last line of the read_file() function, it generates the following code and works perfectly.
Should the std::move(variable) be in the >> operator? In the case of std::ifstream's >> it doesn't work. If we make an exception and not use std::move for >> in general, maybe other overloaded >> operators miss out.
The text was updated successfully, but these errors were encountered:
Describe the bug
cpp2front makes the last usage of a variable be a std::move(variable). In the case the last usage of the variable is for reading a file using std::ifstream's ">> " operator, the generated cpp1 code doesn't compile and gives the following error (and about 10 screens of template errors):
error: no match for ‘operator>>’ (oper
and types are ‘std::ifstream’ {aka ‘std::basic_ifstream’} and ‘std::remove_reference
<std::__cxx11::basic_string&>::type’ {aka ‘std::__cxx11::basic_string’})
24 | read >> temp;
| ~~~~ ^~ ~~~~~
| | |
| | std::remove_reference<std::__cxx11::basic_string&>::t
ype {aka std::__cxx11::basic_string}
| std::ifstream {aka std::basic_ifstream}
To Reproduce
Steps to reproduce the behavior:
Just the generated cpp1 function code:
It should be a move in the general case, but for ifstream std::move() doesn't compile.
Additional context
When I add
temp+=temp;
(just for a dummy last use of it) as the last line of the read_file() function, it generates the following code and works perfectly.Should the std::move(variable) be in the >> operator? In the case of std::ifstream's >> it doesn't work. If we make an exception and not use std::move for >> in general, maybe other overloaded >> operators miss out.
The text was updated successfully, but these errors were encountered: