1#ifndef BOOST_SERIALIZATION_STRONG_TYPEDEF_HPP
2#define BOOST_SERIALIZATION_STRONG_TYPEDEF_HPP
3
4// MS compatible compilers support #pragma once
5#if defined(_MSC_VER)
6# pragma once
7#endif
8
9/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10// strong_typedef.hpp:
11
12// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13// Use, modification and distribution is subject to the Boost Software
14// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15// http://www.boost.org/LICENSE_1_0.txt)
16
17// See http://www.boost.org/libs/serialization for updates, documentation, and revision history.
18
19// macro used to implement a strong typedef. strong typedef
20// guarentees that two types are distinguised even though the
21// share the same underlying implementation. typedef does not create
22// a new type. BOOST_STRONG_TYPEDEF(T, D) creates a new type named D
23// that operates as a type T.
24
25#include <boost/config.hpp>
26#include <boost/operators.hpp>
27
28#if !defined(__BORLANDC__) || __BORLANDC__ >= 0x590
29 #define BOOST_STRONG_TYPEDEF(T, D) \
30 struct D \
31 : boost::totally_ordered1< D \
32 , boost::totally_ordered2< D, T \
33 > > \
34 { \
35 T t; \
36 explicit D(const T t_) : t(t_) {}; \
37 D(): t() {}; \
38 D(const D & t_) : t(t_.t){} \
39 D & operator=(const D & rhs) { t = rhs.t; return *this;} \
40 D & operator=(const T & rhs) { t = rhs; return *this;} \
41 operator const T & () const {return t; } \
42 operator T & () { return t; } \
43 bool operator==(const D & rhs) const { return t == rhs.t; } \
44 bool operator<(const D & rhs) const { return t < rhs.t; } \
45 };
46#else
47 #define BOOST_STRONG_TYPEDEF(T, D) \
48 struct D \
49 : boost::totally_ordered1< D \
50 , boost::totally_ordered2< D, T \
51 > > \
52 { \
53 T t; \
54 explicit D(const T t_) : t(t_) {}; \
55 D() : t(){}; \
56 D(const D & t_) : t(t_.t){} \
57 D & operator=(const D & rhs) { t = rhs.t; return *this;} \
58 D & operator=(const T & rhs) { t = rhs; return *this;} \
59 /*operator const T & () const {return t; }*/ \
60 operator T & () { return t; } \
61 bool operator==(const D & rhs) const { return t == rhs.t; } \
62 bool operator<(const D & rhs) const { return t < rhs.t; } \
63 };
64#endif // !defined(__BORLANDC) || __BORLANDC__ >= 0x590
65
66#endif // BOOST_SERIALIZATION_STRONG_TYPEDEF_HPP
67