1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2015, 2016 Howard Hinnant
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 // class weekday_last
24 // {
25 // public:
26 //     explicit constexpr weekday_last(const date::weekday& wd) noexcept;
27 //
28 //     constexpr date::weekday weekday() const noexcept;
29 //     constexpr bool ok() const noexcept;
30 // };
31 //
32 // constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
33 // constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept;
34 //
35 // std::ostream& operator<<(std::ostream& os, const weekday_last& wdl);
36 
37 #include "date.h"
38 
39 #include <cassert>
40 #include <sstream>
41 #include <type_traits>
42 
43 static_assert( std::is_trivially_destructible<date::weekday_last>{}, "");
44 static_assert(!std::is_default_constructible<date::weekday_last>{}, "");
45 static_assert( std::is_trivially_copy_constructible<date::weekday_last>{}, "");
46 static_assert( std::is_trivially_copy_assignable<date::weekday_last>{}, "");
47 static_assert( std::is_trivially_move_constructible<date::weekday_last>{}, "");
48 static_assert( std::is_trivially_move_assignable<date::weekday_last>{}, "");
49 
50 static_assert(std::is_nothrow_constructible<date::weekday_last, date::weekday>{}, "");
51 static_assert(!std::is_convertible<date::weekday, date::weekday_last>{}, "");
52 
53 int
main()54 main()
55 {
56     using namespace date;
57 
58     constexpr weekday_last wdl = sun[last];
59     static_assert(wdl.weekday() == sun, "");
60     static_assert(wdl.ok(), "");
61     static_assert(wdl == weekday_last{sun}, "");
62     static_assert(wdl != weekday_last{mon}, "");
63     std::ostringstream os;
64     os << wdl;
65     assert(os.str() == "Sun[last]");
66 }
67