#include "boost/date_time/gregorian/gregorian.hpp"
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
#include <set>
void
print_date(boost::gregorian::date d)
{
std::cout << d << " [" << d.day_of_week() << "]\n";
}
int
main() {
std::cout << "Enter Year: ";
int year;
std::cin >> year;
using namespace boost::gregorian;
std::vector<partial_date> holidays;
holidays.push_back(partial_date(1, Jan));
holidays.push_back(partial_date(4, Jul));
holidays.push_back(partial_date(25, Dec));
typedef boost::date_time::nth_kday_of_month<date> nkday;
std::vector<nkday> more_holidays;
more_holidays.push_back(nkday(nkday::first, Monday, Sep));
more_holidays.push_back(nkday(nkday::third, Monday, Jan));
more_holidays.push_back(nkday(nkday::second, Tuesday, Feb));
more_holidays.push_back(nkday(nkday::fourth, Thursday, Nov));
typedef std::set<date> date_set;
date_set all_holidays;
#if (defined(BOOST_MSVC) && (_MSC_VER <= 1200))
std::cout << "Sorry, this example temporarily disabled on VC 6.\n"
<< "The std::transform isn't accepted by the compiler\n"
<< "So if you hack up the example without std::transform\n"
<< "it should work\n"
<< std::endl;
#else
std::transform(holidays.begin(), holidays.end(),
std::insert_iterator<date_set>(all_holidays, all_holidays.begin()),
std::bind2nd(std::mem_fun_ref(&partial_date::get_date),
year));
std::transform(more_holidays.begin(), more_holidays.end(),
std::insert_iterator<date_set>(all_holidays, all_holidays.begin()),
std::bind2nd(std::mem_fun_ref(&nkday::get_date),
year));
std::for_each(all_holidays.begin(), all_holidays.end(), print_date);
std::cout << "Number Holidays: " << all_holidays.size() << std::endl;
#endif
return 0;
}