Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
typedef string::const_iterator State;
Def expr(string& s,State &i);
Def term(string& s,State &i);
Def factor(string& s,State &i);
Def number(string& s,State &i);
void consume(State &i,char expected){
	if(*i==expected)i++;
	else{
		cerr<<"!"<<endl;
	}
}
Def expr(string& s,State &i){
	Def out=term(s,i);
	while(*i=='+'||*i=='-'){
		char op=*i;
		i++;
		Def out1=term(s,i);
		if(op=='+')out+=out1;
		else out-=out1;
	}
	return out;
}
Def term(string& s,State &i){
	Def out=factor(s,i);
	while(*i=='*'||*i=='/'){
		char op=*i;
		i++;
		Def out1=factor(s,i);
		if(op=='*')out*=out1;
		else out/=out1;
	}
	return out;
}
Def factor(string& s,State &i){
	if(isdigit(*i))return number(s,i);
	//'('
	i++;
	Def out=expr(s,i);
	i++;
	return out;
}
Def number(string& s,State &i){
	Def out=0;
	while(isdigit(*i))out=out*10+*(i++)-'0';
	return out;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		cout<<expr(s,s.begin())<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:101:37: error: cannot bind non-const lvalue reference of type 'State&' {aka 'std::__cxx11::basic_string<char>::const_iterator&'} to an rvalue of type 'State' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
  101 |                 cout<<expr(s,s.begin())<<endl;
      |                              ~~~~~~~^~
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:1074:9: note:   after user-defined conversion: '__gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator(const __gnu_cxx::__normal_iterator<_Iter, _Container>&) [with _Iter = char*; <template-parameter-2-2> = void; _Iterator = const char*; _Container = std::__cxx11::basic_string<char>]'
 1074 |         __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
      |         ^~~~~~~~~~~~~~~~~
a.cc:60:27: note:   initializing argument 2 of 'Def expr(std::string&, State&)'
   60 | Def expr(string& s,State &i){
      |                    ~~~~~~~^