#include <iostream>
#include <sstream>
using namespace std;
struct chlit
{
chlit(char c) : c_(c) { }
friend std::istream& operator>>(std::istream& is, chlit x)
{
char c;
if (is >> c && c != x.c_)
is.setstate(std::iostream::failbit);
return is;
}
char c_;
};
int main()
{
std::istringstream iss("(12, -34.78)");
int a; double b;
if (iss >> chlit('(') >> a >> chlit(',') >> b >> chlit(')'))
std::cout << " a=" << a << " b=" << b << '\n';
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3N0cmVhbT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgogICAgc3RydWN0IGNobGl0CiAgICB7CiAgICAJY2hsaXQoY2hhciBjKSA6IGNfKGMpIHsgfQogICAgICAgIGZyaWVuZCBzdGQ6OmlzdHJlYW0mIG9wZXJhdG9yPj4oc3RkOjppc3RyZWFtJiBpcywgY2hsaXQgeCkKICAgICAgICB7CiAgICAgICAgCWNoYXIgYzsKICAgICAgICAJaWYgKGlzID4+IGMgJiYgYyAhPSB4LmNfKQogICAgICAgIAkgICAgaXMuc2V0c3RhdGUoc3RkOjppb3N0cmVhbTo6ZmFpbGJpdCk7CiAgICAgICAgCXJldHVybiBpczsKICAgICAgICB9CiAgICAgICAgY2hhciBjXzsKICAgIH07CgppbnQgbWFpbigpCnsKCXN0ZDo6aXN0cmluZ3N0cmVhbSBpc3MoIigxMiwgLTM0Ljc4KSIpOwoJaW50IGE7IGRvdWJsZSBiOwoJaWYgKGlzcyA+PiBjaGxpdCgnKCcpID4+IGEgPj4gY2hsaXQoJywnKSA+PiBiID4+IGNobGl0KCcpJykpCgkgICAgc3RkOjpjb3V0IDw8ICIgYT0iIDw8IGEgPDwgIiBiPSIgPDwgYiA8PCAnXG4nOwp9