Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

This commit is contained in:
Edward Diener
2020-04-25 01:00:03 -04:00
parent 1d57e5add8
commit 88e45e951b
2 changed files with 123 additions and 0 deletions

View File

@@ -130,6 +130,9 @@ namespace date_time {
}
//
#if !defined(BOOST_EMBTC)
BOOST_CXX14_CONSTEXPR friend date_type operator+(const date_type& d, const months_type& m)
{
return d + m.get_offset(d);
@@ -149,10 +152,42 @@ namespace date_time {
return d += m.get_neg_offset(d);
}
#else
BOOST_CXX14_CONSTEXPR friend date_type operator+(const date_type& d, const months_type& m);
BOOST_CXX14_CONSTEXPR friend date_type operator+=(date_type& d, const months_type& m);
BOOST_CXX14_CONSTEXPR friend date_type operator-(const date_type& d, const months_type& m);
BOOST_CXX14_CONSTEXPR friend date_type operator-=(date_type& d, const months_type& m);
#endif
private:
int_rep _m;
};
#if defined(BOOST_EMBTC)
inline BOOST_CXX14_CONSTEXPR date_type operator+(const date_type& d, const months_type& m)
{
return d + m.get_offset(d);
}
inline BOOST_CXX14_CONSTEXPR date_type operator+=(date_type& d, const months_type& m)
{
return d += m.get_offset(d);
}
inline BOOST_CXX14_CONSTEXPR date_type operator-(const date_type& d, const months_type& m)
{
// get_neg_offset returns a negative duration, so we add
return d + m.get_neg_offset(d);
}
inline BOOST_CXX14_CONSTEXPR date_type operator-=(date_type& d, const months_type& m)
{
// get_neg_offset returns a negative duration, so we add
return d += m.get_neg_offset(d);
}
#endif
//! additional duration type that represents a logical year
/*! A logical year enables things like: "date(2002,Mar,2) + years(2) ->
* 2004-Mar-2". If the date is a last day-of-the-month, the result will
@@ -242,6 +277,9 @@ namespace date_time {
}
//
#if !defined(BOOST_EMBTC)
BOOST_CXX14_CONSTEXPR friend date_type operator+(const date_type& d, const years_type& y)
{
return d + y.get_offset(d);
@@ -261,10 +299,42 @@ namespace date_time {
return d += y.get_neg_offset(d);
}
#else
BOOST_CXX14_CONSTEXPR friend date_type operator+(const date_type& d, const years_type& y);
BOOST_CXX14_CONSTEXPR friend date_type operator+=(date_type& d, const years_type& y);
BOOST_CXX14_CONSTEXPR friend date_type operator-(const date_type& d, const years_type& y);
BOOST_CXX14_CONSTEXPR friend date_type operator-=(date_type& d, const years_type& y);
#endif
private:
int_rep _y;
};
#if defined(BOOST_EMBTC)
inline BOOST_CXX14_CONSTEXPR date_type operator+(const date_type& d, const years_type& y)
{
return d + y.get_offset(d);
}
inline BOOST_CXX14_CONSTEXPR date_type operator+=(date_type& d, const years_type& y)
{
return d += y.get_offset(d);
}
inline BOOST_CXX14_CONSTEXPR date_type operator-(const date_type& d, const years_type& y)
{
// get_neg_offset returns a negative duration, so we add
return d + y.get_neg_offset(d);
}
inline BOOST_CXX14_CONSTEXPR date_type operator-=(date_type& d, const years_type& y)
{
// get_neg_offset returns a negative duration, so we add
return d += y.get_neg_offset(d);
}
#endif
}} // namespace boost::date_time
#endif // DATE_DURATION_TYPES_HPP___

View File

@@ -84,6 +84,9 @@ namespace gregorian {
base_type::operator-= (rhs);
return *this;
}
#if !defined(BOOST_EMBTC)
BOOST_CXX14_CONSTEXPR friend
date_duration operator- (date_duration rhs, date_duration const& lhs)
{
@@ -91,12 +94,22 @@ namespace gregorian {
return rhs;
}
#else
BOOST_CXX14_CONSTEXPR friend
date_duration operator- (date_duration rhs, date_duration const& lhs);
#endif
//! Add a duration -- result is signed
BOOST_CXX14_CONSTEXPR date_duration& operator+= (const date_duration& rhs)
{
base_type::operator+= (rhs);
return *this;
}
#if !defined(BOOST_EMBTC)
BOOST_CXX14_CONSTEXPR friend
date_duration operator+ (date_duration rhs, date_duration const& lhs)
{
@@ -104,6 +117,13 @@ namespace gregorian {
return rhs;
}
#else
BOOST_CXX14_CONSTEXPR friend
date_duration operator+ (date_duration rhs, date_duration const& lhs);
#endif
//! unary- Allows for dd = -date_duration(2); -> dd == -2
BOOST_CXX14_CONSTEXPR date_duration operator- ()const
{
@@ -116,12 +136,21 @@ namespace gregorian {
base_type::operator/= (divisor);
return *this;
}
#if !defined(BOOST_EMBTC)
BOOST_CXX14_CONSTEXPR friend date_duration operator/ (date_duration rhs, int lhs)
{
rhs /= lhs;
return rhs;
}
#else
BOOST_CXX14_CONSTEXPR friend date_duration operator/ (date_duration rhs, int lhs);
#endif
//! Returns the smallest duration -- used by to calculate 'end'
static BOOST_CXX14_CONSTEXPR date_duration unit()
{
@@ -129,6 +158,30 @@ namespace gregorian {
}
};
#if defined(BOOST_EMBTC)
inline BOOST_CXX14_CONSTEXPR
date_duration operator- (date_duration rhs, date_duration const& lhs)
{
rhs -= lhs;
return rhs;
}
inline BOOST_CXX14_CONSTEXPR
date_duration operator+ (date_duration rhs, date_duration const& lhs)
{
rhs += lhs;
return rhs;
}
inline BOOST_CXX14_CONSTEXPR date_duration operator/ (date_duration rhs, int lhs)
{
rhs /= lhs;
return rhs;
}
#endif
//! Shorthand for date_duration
typedef date_duration days;