@@ -10,16 +10,45 @@ BEGIN_NAMESPACE(cpp_study)
1010class SalesData final
1111{
1212public:
13- using this_type = SalesData;
13+ using this_type = SalesData;
1414
1515public:
16- using string_type = std::string;
17- using uint_type = unsigned int ;
18- using currency_type = double ;
16+ using string_type = std::string;
17+ using string_view_type = const std::string&;
18+ using uint_type = unsigned int ;
19+ using currency_type = double ;
1920
2021 STATIC_ASSERT (sizeof (uint_type) >= 4 );
2122 STATIC_ASSERT (sizeof (currency_type) >= 4 );
2223public:
24+ SalesData (string_view_type id, uint_type s, currency_type r) noexcept
25+ : m_id (id), m_sold (s), m_revenue (r)
26+ {}
27+
28+ SalesData (string_view_type id) noexcept
29+ : SalesData (id, 0 , 0 )
30+ {}
31+
32+ public:
33+ SalesData (SalesData&& s) noexcept
34+ {
35+ m_id = std::move (s.m_id );
36+ m_sold = s.m_sold ;
37+ m_revenue = s.m_revenue ;
38+ }
39+
40+ SalesData& operator =(SalesData&& s) noexcept
41+ {
42+ m_id = std::move (s.m_id );
43+ m_sold = s.m_sold ;
44+ m_revenue = s.m_revenue ;
45+
46+ return *this ;
47+ }
48+
49+ SalesData (const SalesData&) = default ;
50+ SalesData& operator =(const SalesData&) = default ;
51+
2352 SalesData () = default ;
2453 ~SalesData () = default ;
2554
@@ -29,17 +58,17 @@ class SalesData final
2958 uint_type m_revenue = 0 ;
3059
3160public:
32- const string_type& id () const
61+ string_view_type id () const noexcept
3362 {
3463 return m_id;
3564 }
3665
37- uint_type sold () const
66+ uint_type sold () const noexcept
3867 {
3968 return m_sold;
4069 }
4170
42- currency_type revenue () const
71+ currency_type revenue () const noexcept
4372 {
4473 return m_revenue;
4574 }
0 commit comments