Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
  	cin >> str;
  	int q;
  	cin >> q;
  	int r = 0;
  
  	vector<char> ch;
  	vector<int> par;
  	vector<int> rev;
  
  	while (q-- > 0) {
      int t;
      cin >> t;
      if (t == 2) {
        char s; int p;
        cin >> p >> s;
        ch.push_back(s);
        par.push_back(p - 1);
        rev.push_back(r);
      } else {
        r++;
        r%=2;
      }
    }
  	deque<char> dq;
  	dq.push_back(str[0]);
  	for (int i = 0; i < ch.size(); i++) {
      if ((par[i] + r - rev[i] + 2) % 2) dq.push_back(ch[i]);
      else dq.push_front(ch[i]);
    }
  	str = "";
  	for (int i = 0; i < dq.size(); i++) str += dq.pop_front();
  	cout << str << endl;
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:49: error: no match for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'void')
   35 |         for (int i = 0; i < dq.size(); i++) str += dq.pop_front();
      |                                             ~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:1424:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1424 |         operator+=(const _Tp& __svt)
      |         ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1424:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/basic_string.h: In substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = void; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]':
/usr/include/c++/14/bits/basic_string.h:1424:2:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::operator+=(const _Tp&) [with _Tp = void]'
a.cc:35:60:   required from here
   35 |         for (int i = 0; i < dq.size(); i++) str += dq.pop_front();
      |                                                                 ^
/usr/include/c++/14/bits/basic_string.h:152:70: error: forming reference to void
  152 |                  __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
      |                                                                      ^~~~~
/usr/include/c++/14/bits/basic_string.h:1377:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1377 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1377:38: note:   no known conversion for argument 1 from 'void' to 'const std::__cxx11::basic_string<char>&'
 1377 |       operator+=(const basic_string& __str)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:1387:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1387 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1387:32: note:   no known conversion for argument 1 from 'void' to 'const char*'
 1387 |       operator+=(const _CharT* __s)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:1397:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1397 |       operator+=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1397:25: note:   no known conversion for argument 1 from 'void' to 'char'
 1397 |       operator+=(_CharT __c)
      |                  ~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:1411:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1411 |       operator+=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1411:43: note:   no known conversion for argument 1 from 'void' to 'std::initializer_list<char>'
 1411 |       operator+=(initializer_list<_CharT> __l)
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~