Language: C++

#include <iostream>
#include <string>
#include <sstream>
#include <regex>
using namespace std;


int main() {
	string str;
	getline(cin, str);
	stringstream ss(str);

	while (!ss.eof()) {
		ss >> str;
		string tmp = "";

		tmp = regex_replace(str,"apple", "peach");
		if (str == tmp) {
			tmp = regex_replace(str, "peach", "apple");
		}

		cout << tmp << (!ss.eof() ? ' ' : '\n');	
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:36: error: no matching function for call to 'regex_replace(std::string&, const char [6], const char [6])'
   17 |                 tmp = regex_replace(str,"apple", "peach");
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/regex:68,
                 from a.cc:4:
/usr/include/c++/14/bits/regex.h:2576:5: note: candidate: 'template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type, class _St, class _Sa> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const __cxx11::basic_string<_Ch_type, _St, _Sa>&, regex_constants::match_flag_type)'
 2576 |     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2576:5: note:   candidate expects 5 arguments, 3 provided
/usr/include/c++/14/bits/regex.h:2602:5: note: candidate: 'template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, regex_constants::match_flag_type)'
 2602 |     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2602:5: note:   candidate expects 5 arguments, 3 provided
/usr/include/c++/14/bits/regex.h:2628:5: note: candidate: 'template<class _Rx_traits, class _Ch_type, class _St, class _Sa, class _Fst, class _Fsa> std::__cxx11::basic_string<_Ch_type, _St, _Sa> std::regex_replace(const __cxx11::basic_string<_Ch_type, _St, _Sa>&, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const __cxx11::basic_string<_Ch_type, _Fst, _Fsa>&, regex_constants::match_flag_type)'
 2628 |     regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2628:5: note:   template argument deduction/substitution failed:
a.cc:17:36: note:   mismatched types 'const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>' and 'const char [6]'
   17 |                 tmp = regex_replace(str,"apple", "peach");
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2654:5: note: candidate: 'template<class _Rx_traits, class _Ch_type, class _St, class _Sa> std::__cxx11::basic_string<_Ch_type, _St, _Sa> std::regex_replace(const __cxx11::basic_string<_Ch_type, _St, _Sa>&, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, regex_constants::match_flag_type)'
 2654 |     regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2654:5: note:   template argument deduction/substitution failed:
a.cc:17:36: note:   mismatched types 'const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>' and 'const char [6]'
   17 |                 tmp = regex_replace(str,"apple", "peach");
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2680:5: note: candidate: 'template<class _Rx_traits, class _Ch_type, class _St, class _Sa> std::__cxx11::basic_string<_Ch_type> std::regex_replace(const _Ch_type*, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const __cxx11::basic_string<_Ch_type, _St, _Sa>&, regex_constants::match_flag_type)'
 2680 |     regex_replace(const _Ch_type* __s,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2680:5: note:   template argument deduction/substitution failed:
a.cc:17:36: note:   mismatched types 'const _Ch_type*' and 'std::__cxx11::basic_string<char>'
   17 |                 tmp = regex_replace(str,"apple", "peach");
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2706:5: note: candidate: 'template<class _Rx_traits, class _Ch_type> std::__cxx11::basic_string<_Ch_type> std::regex_replace(const _Ch_type*, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, regex_constants::match_flag_type)'
 2706 |     regex_replace(const _Ch_type* __s,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2706:5: note:   template argument deduction/substitution failed:
a.cc:17:36: note:   mismatched types 'const _Ch_type*' and 'std::__cxx11::basic_string<char>'
   17 |                 tmp = regex_replace(str,"apple", "peach");
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:19:44: error: no matching function for call to 'regex_replace(std::string&, const char [6], const char [6])'
   19 |                         tmp = regex_replace(str, "peach", "apple");
      |                               ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2576:5: note: candidate: 'template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type, class _St, class _Sa> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const __cxx11::basic_string<_Ch_type, _St, _Sa>&, regex_constants::match_flag_type)'
 2576 |     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2576:5: note:   candidate expects 5 arguments, 3 provided
/usr/include/c++/14/bits/regex.h:2602:5: note: candidate: 'template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, regex_constants::match_flag_type)'
 2602 |     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2602:5: note:   candidate expects 5 arguments, 3 provided
/usr/include/c++/14/bits/regex.h:2628:5: note: candidate: 'template<class _Rx_traits, class _Ch_type, class _St, class _Sa, class _Fst, class _Fsa> std::__cxx11::basic_string<_Ch_type, _St, _Sa> std::regex_replace(const __cxx11::basic_string<_Ch_type, _St, _Sa>&, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const __cxx11::basic_string<_Ch_type, _Fst, _Fsa>&, regex_constants::match_flag_type)'
 2628 |     regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2628:5: note:   template argument deduction/substitution failed:
a.cc:19:44: note:   mismatched types 'const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>' and 'const char [6]'
   19 |                         tmp = regex_replace(str, "peach", "apple");
      |                               ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2654:5: note: candidate: 'template<class _Rx_traits, class _Ch_type, class _St, class _Sa> std::__cxx11::basic_string<_Ch_type, _St, _Sa> std::regex_replace(const __cxx11::basic_string<_Ch_type, _St, _Sa>&, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, regex_constants::match_flag_type)'
 2654 |     regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2654:5: note:   template argument deduction/substitution failed:
a.cc:19:44: note:   mismatched types 'const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>' and 'const char [6]'
   19 |                         tmp = regex_replace(str, "peach", "apple");
      |                               ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2680:5: note: candidate: 'template<class _Rx_traits, class _Ch_type, class _St, class _Sa> std::__cxx11::basic_string<_Ch_type> std::regex_replace(const _Ch_type*, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const __cxx11::basic_string<_Ch_type, _St, _Sa>&, regex_constants::match_flag_type)'
 2680 |     regex_replace(const _Ch_type* __s,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2680:5: note:   template argument deduction/substitution failed:
a.cc:19:44: note:   mismatched types 'const _Ch_type*' and 'std::__cxx11::basic_string<char>'
   19 |                         tmp = regex_replace(str, "peach", "apple");
      |                               ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2706:5: note: candidate: 'template<class _Rx_traits, class _Ch_type> std::__cxx11::basic_string<_Ch_type> std::regex_replace(const _Ch_type*, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, regex_constants::match_flag_type)'
 2706 |     regex_replace(const _Ch_type* __s,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2706:5: note:   template argument deduction/substitution failed:
a.cc:19:44: note:   mismatched types 'const _Ch_type*' and 'std::__cxx11::basic_string<char>'
   19 |                         tmp = regex_replace(str, "peach", "apple");
      |                               ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~