How Can I Tell if My struct tm Has Been Left in an Invalid State?
问题 This is a question about invalid input, not invalid formatting. For example given the following code: tm bar; foo >> get_time(&bar, "%Y-%m-%d"); cout >> bar.tm_year >> bar.tm_mon >> bar.tm_mday >> endl; This is fine if I define: stringstream foo("2001-02-28 non-leap year"); And has a clear error if I have invalid format such as: stringstream foo("bad format 2001-02-28 non-leap year"); But I don't know how to detect if my input was invalid for example: stringstream foo("2001-02-30 non-leap