Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:08:14

0001 #ifndef BOOST_SERIALIZATION_STRONG_TYPEDEF_HPP
0002 #define BOOST_SERIALIZATION_STRONG_TYPEDEF_HPP
0003 
0004 // MS compatible compilers support #pragma once
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008 
0009 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0010 // strong_typedef.hpp:
0011 
0012 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0013 // (C) Copyright 2016 Ashish Sadanandan
0014 // Use, modification and distribution is subject to the Boost Software
0015 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 //  See http://www.boost.org/libs/serialization for updates, documentation, and revision history.
0019 
0020 // macro used to implement a strong typedef.  strong typedef
0021 // guarantees that two types are distinguished even though they
0022 // share the same underlying implementation.  typedef does not create
0023 // a new type.  BOOST_STRONG_TYPEDEF(T, D) creates a new type named D
0024 // that operates as a type T.
0025 
0026 #include <boost/config.hpp>
0027 #include <boost/operators.hpp>
0028 #include <boost/type_traits/has_nothrow_assign.hpp>
0029 #include <boost/type_traits/has_nothrow_constructor.hpp>
0030 #include <boost/type_traits/has_nothrow_copy.hpp>
0031 
0032 #define BOOST_STRONG_TYPEDEF(T, D)                                                                               \
0033 struct D                                                                                                         \
0034     : boost::totally_ordered1< D                                                                                 \
0035     , boost::totally_ordered2< D, T                                                                              \
0036     > >                                                                                                          \
0037 {                                                                                                                \
0038     T t;                                                                                                         \
0039     explicit D(const T& t_) BOOST_NOEXCEPT_IF(boost::has_nothrow_copy_constructor<T>::value) : t(t_) {}          \
0040     D() BOOST_NOEXCEPT_IF(boost::has_nothrow_default_constructor<T>::value) : t() {}                             \
0041     D(const D & t_) BOOST_NOEXCEPT_IF(boost::has_nothrow_copy_constructor<T>::value) : t(t_.t) {}                \
0042     D& operator=(const D& rhs) BOOST_NOEXCEPT_IF(boost::has_nothrow_assign<T>::value) {t = rhs.t; return *this;} \
0043     D& operator=(const T& rhs) BOOST_NOEXCEPT_IF(boost::has_nothrow_assign<T>::value) {t = rhs; return *this;}   \
0044     operator const T&() const {return t;}                                                                        \
0045     operator T&() {return t;}                                                                                    \
0046     bool operator==(const D& rhs) const {return t == rhs.t;}                                                     \
0047     bool operator<(const D& rhs) const {return t < rhs.t;}                                                       \
0048 };
0049 
0050 #endif // BOOST_SERIALIZATION_STRONG_TYPEDEF_HPP