Skip to content

Commit

Permalink
Merge pull request #62 from jeking3/trac-3606
Browse files Browse the repository at this point in the history
trac-3606: fix remaining msvc /W4 complaints (msvc-10.0 and up)
  • Loading branch information
jeking3 committed Jan 18, 2018
2 parents f280794 + e0da181 commit 313c1a3
Show file tree
Hide file tree
Showing 31 changed files with 399 additions and 395 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
**/time_duration_serialization.*
**/test_facet_file.out
**/time_duration_serialization.*
2 changes: 0 additions & 2 deletions doc/build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

project libs/date_time/doc ;

###############################################################################
alias boostdoc
: ../xmldoc/date_time.xml
Expand Down
3 changes: 2 additions & 1 deletion example/gregorian/find_last_day_of_months.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ main()

// get a month and a year from the user
try {
int y, m;
greg_year::value_type y;
greg_month::value_type m;
std::cout << " Enter Year(ex: 2002): ";
std::cin >> y;
year = greg_year(y);
Expand Down
6 changes: 3 additions & 3 deletions example/gregorian/print_holidays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ print_date(boost::gregorian::date d)
int
main() {

using namespace boost::gregorian;

std::cout << "Enter Year: ";
int year;
greg_year::value_type year;
std::cin >> year;

using namespace boost::gregorian;

//define a collection of holidays fixed by month and day
std::vector<year_based_generator*> holidays;
holidays.push_back(new partial_date(1,Jan)); //Western New Year
Expand Down
8 changes: 5 additions & 3 deletions example/gregorian/print_month.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
int
main()
{
using namespace boost::gregorian;

std::cout << "Enter Year: ";
int year, month;
greg_year::value_type year;
greg_month::value_type month;
std::cin >> year;
std::cout << "Enter Month(1..12): ";
std::cin >> month;

using namespace boost::gregorian;
try {
//Use the calendar to get the last day of the month
int eom_day = gregorian_calendar::end_of_month_day(year,month);
greg_day::value_type eom_day = gregorian_calendar::end_of_month_day(year,month);
date endOfMonth(year,month,eom_day);

//construct an iterator starting with firt day of the month
Expand Down
104 changes: 52 additions & 52 deletions include/boost/date_time/gregorian/gregorian_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, d);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, d);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, d);
Expand Down Expand Up @@ -138,14 +138,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, dd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, dd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, dd);
Expand Down Expand Up @@ -202,14 +202,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, dp);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, dp);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, dp);
Expand Down Expand Up @@ -261,14 +261,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, m);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, m);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, m);
Expand Down Expand Up @@ -318,14 +318,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, wd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, wd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, wd);
Expand Down Expand Up @@ -359,14 +359,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, gd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, gd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, gd);
Expand Down Expand Up @@ -400,14 +400,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, gy);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, gy);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, gy);
Expand Down Expand Up @@ -458,14 +458,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, pd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, pd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, pd);
Expand Down Expand Up @@ -515,14 +515,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, nday);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, nday);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, nday);
Expand Down Expand Up @@ -573,14 +573,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fkd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fkd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fkd);
Expand Down Expand Up @@ -631,14 +631,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, lkd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, lkd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, lkd);
Expand Down Expand Up @@ -690,14 +690,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fka);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fka);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fka);
Expand Down Expand Up @@ -749,14 +749,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fkb);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fkb);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fkb);
Expand Down
24 changes: 12 additions & 12 deletions include/boost/date_time/posix_time/posix_time_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ namespace posix_time {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<time_input_facet>(is.getloc())) {
std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, pt);
if(std::has_facet<time_input_facet_local>(is.getloc())) {
std::use_facet<time_input_facet_local>(is.getloc()).get(sit, str_end, is, pt);
}
else {
time_input_facet* f = new time_input_facet();
time_input_facet_local* f = new time_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, pt);
Expand Down Expand Up @@ -141,13 +141,13 @@ namespace posix_time {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<time_input_facet>(is.getloc())) {
std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, tp);
if(std::has_facet<time_input_facet_local>(is.getloc())) {
std::use_facet<time_input_facet_local>(is.getloc()).get(sit, str_end, is, tp);
}
else {
time_input_facet* f = new time_input_facet();
time_input_facet_local* f = new time_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, tp);
Expand Down Expand Up @@ -205,13 +205,13 @@ namespace posix_time {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<time_input_facet>(is.getloc())) {
std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, td);
if(std::has_facet<time_input_facet_local>(is.getloc())) {
std::use_facet<time_input_facet_local>(is.getloc()).get(sit, str_end, is, td);
}
else {
time_input_facet* f = new time_input_facet();
time_input_facet_local* f = new time_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, td);
Expand Down
2 changes: 2 additions & 0 deletions include/boost/date_time/time_facet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ namespace date_time {
break;
// %s is the same as %S%f so we drop through into %f
}
/* Falls through. */
case 'f':
{
// check for decimal, check special_values if missing
Expand Down Expand Up @@ -1139,6 +1140,7 @@ namespace date_time {
// %s is the same as %S%f so we drop through into %f if we are
// not at the end of the stream
}
/* Falls through. */
case 'f':
{
// check for decimal, check SV if missing
Expand Down
6 changes: 3 additions & 3 deletions test/gregorian/testdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ main()
date def;
check("Default constructor", def == date(not_a_date_time));
#endif
date d(2000,1,1);

date d1(1900,1,1);
date d2 = d;
date d2 = date(2000,1,1);
date d3(d2);
check("Copy constructor", d3 == d2);
date d4(2000,12,31);
Expand Down Expand Up @@ -276,7 +276,7 @@ main()
}

//converts to date and back -- should get same result
check_equal("tm conversion functions 2000-1-1", date_from_tm(to_tm(d)), d);
check_equal("tm conversion functions 2000-1-1", date_from_tm(to_tm(d2)), d2);
check_equal("tm conversion functions 1900-1-1", date_from_tm(to_tm(d1)), d1);
check_equal("tm conversion functions min date 1400-1-1 ", date_from_tm(to_tm(d14)), d14);
check_equal("tm conversion functions max date 9999-12-31", date_from_tm(to_tm(d13)), d13);
Expand Down
Loading

0 comments on commit 313c1a3

Please sign in to comment.