]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef BOOST_SERIALIZATION_COLLECTION_SIZE_TYPE_HPP |
2 | #define BOOST_SERIALIZATION_COLLECTION_SIZE_TYPE_HPP | |
3 | ||
4 | // (C) Copyright 2005 Matthias Troyer | |
5 | // Use, modification and distribution is subject to the Boost Software | |
6 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | #include <cstddef> // size_t | |
10 | #include <boost/serialization/strong_typedef.hpp> | |
11 | #include <boost/serialization/level.hpp> | |
12 | #include <boost/serialization/split_free.hpp> | |
13 | #include <boost/serialization/is_bitwise_serializable.hpp> | |
14 | ||
f67539c2 | 15 | namespace boost { |
7c673cae FG |
16 | namespace serialization { |
17 | ||
18 | //BOOST_STRONG_TYPEDEF(std::size_t, collection_size_type) | |
19 | ||
20 | class collection_size_type { | |
21 | private: | |
22 | typedef std::size_t base_type; | |
23 | base_type t; | |
24 | public: | |
92f5a8d4 | 25 | collection_size_type(): t(0) {} |
f67539c2 | 26 | explicit collection_size_type(const std::size_t & t_) : |
7c673cae FG |
27 | t(t_) |
28 | {} | |
f67539c2 | 29 | collection_size_type(const collection_size_type & t_) : |
7c673cae FG |
30 | t(t_.t) |
31 | {} | |
32 | collection_size_type & operator=(const collection_size_type & rhs){ | |
f67539c2 | 33 | t = rhs.t; |
7c673cae FG |
34 | return *this; |
35 | } | |
36 | collection_size_type & operator=(const unsigned int & rhs){ | |
f67539c2 | 37 | t = rhs; |
7c673cae FG |
38 | return *this; |
39 | } | |
40 | // used for text output | |
41 | operator base_type () const { | |
42 | return t; | |
f67539c2 | 43 | } |
7c673cae FG |
44 | // used for text input |
45 | operator base_type & () { | |
46 | return t; | |
f67539c2 | 47 | } |
7c673cae FG |
48 | bool operator==(const collection_size_type & rhs) const { |
49 | return t == rhs.t; | |
f67539c2 | 50 | } |
7c673cae FG |
51 | bool operator<(const collection_size_type & rhs) const { |
52 | return t < rhs.t; | |
f67539c2 | 53 | } |
7c673cae FG |
54 | }; |
55 | ||
56 | ||
57 | } } // end namespace boost::serialization | |
58 | ||
59 | BOOST_CLASS_IMPLEMENTATION(collection_size_type, primitive_type) | |
60 | BOOST_IS_BITWISE_SERIALIZABLE(collection_size_type) | |
61 | ||
62 | #endif //BOOST_SERIALIZATION_COLLECTION_SIZE_TYPE_HPP |