Simplify the implementation of format and parse:

* For format, all a type must do is implement to_stream.

* For parse, each type X must specialize parse_manip<X,CharT,Traits>.
  Each specialization must include a public typedef to itself named
  type.

* Each parse_manip specialization must have a stream extraction
  operator.

* This commit depends on expression-SFINAE.  If this commit breaks
  your build, it is likely that your compiler/version does not
  support expression-SFINAE.  To fix this NO_EXPRESSION_SFINAE
  needs to be defined in the configuration area of date.h for
  that compiler/version.
This commit is contained in:
Howard Hinnant
2017-02-26 14:10:10 -05:00
parent ffc8cd0a3b
commit 1e7e7a214d
4 changed files with 513 additions and 942 deletions
+8
View File
@@ -67,4 +67,12 @@ main()
os.str("");
os << format("%F %T", sys_days{dec/last/year::max()} + microfortnights{1});
assert(os.str() == "32767-12-31 00:00:01.2096");
os.str("");
os << format("%F %T", jan/1/year::min());
assert(os.str() == "-32768-01-01 00:00:00");
os.str("");
os << format("%F %T", dec/last/year::max());
assert(os.str() == "32767-12-31 00:00:00");
os.str("");
}