Skip to content

Commit

Permalink
Rework deprecation control for better flexibility, and move up ST::null
Browse files Browse the repository at this point in the history
deprecation to version 3.4
  • Loading branch information
zrax committed Nov 6, 2020
1 parent 9afe063 commit 2dca62c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
14 changes: 7 additions & 7 deletions include/st_charbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace ST
constexpr null_t() noexcept { }
};

ST_DEPRECATED_IN_4_0("Use empty initializer {} instead.")
ST_DEPRECATED_IN_3_4("Use empty initializer {} instead.")
static constexpr null_t null;

template <typename char_T>
Expand Down Expand Up @@ -88,7 +88,7 @@ namespace ST
constexpr buffer() noexcept
: m_chars(m_data), m_size(), m_data() { }

ST_DEPRECATED_IN_4_0("Use empty initializer {} instead.")
ST_DEPRECATED_IN_3_4("Use empty initializer {} instead.")
constexpr buffer(const null_t &) noexcept
: m_chars(m_data), m_size(), m_data() { }

Expand Down Expand Up @@ -146,7 +146,7 @@ namespace ST
traits_t::assign(m_data, local_length, 0);
}

ST_DEPRECATED_IN_4_0("Use clear() instead")
ST_DEPRECATED_IN_3_4("Use clear() instead")
buffer<char_T> &operator=(const null_t &) noexcept
{
clear();
Expand Down Expand Up @@ -230,7 +230,7 @@ namespace ST
}

ST_NODISCARD
ST_DEPRECATED_IN_4_0("Use empty() instead")
ST_DEPRECATED_IN_3_4("Use empty() instead")
bool operator==(const null_t &) const noexcept
{
return empty();
Expand All @@ -243,7 +243,7 @@ namespace ST
}

ST_NODISCARD
ST_DEPRECATED_IN_4_0("Use !empty() instead")
ST_DEPRECATED_IN_3_4("Use !empty() instead")
bool operator!=(const null_t &) const noexcept
{
return !empty();
Expand Down Expand Up @@ -441,15 +441,15 @@ namespace ST

template <typename char_T>
ST_NODISCARD
ST_DEPRECATED_IN_4_0("Use buffer<T>::empty() instead")
ST_DEPRECATED_IN_3_4("Use buffer<T>::empty() instead")
bool operator==(const null_t &, const buffer<char_T> &right) noexcept
{
return right.empty();
}

template <typename char_T>
ST_NODISCARD
ST_DEPRECATED_IN_4_0("Use !buffer<T>::empty() instead")
ST_DEPRECATED_IN_3_4("Use !buffer<T>::empty() instead")
bool operator!=(const null_t &, const buffer<char_T> &right) noexcept
{
return !right.empty();
Expand Down
27 changes: 19 additions & 8 deletions include/st_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,30 @@
# define ST_DEPRECATED(message)
#endif

#if defined(ST_NO_3_0_DEPRECATION)
# define ST_DEPRECATED_IN_3_0(message)
#else
# define ST_DEPRECATED_IN_3_0(message) ST_DEPRECATED(message)
#ifndef ST_DEPRECATED_VERSION
# if defined(ST_NO_3_0_DEPRECATION)
# define ST_DEPRECATED_VERSION 299
# else
# define ST_DEPRECATED_VERSION ST_VERSION
# endif
#endif

#if !defined(ST_4_0_DEPRECATION)
# define ST_NO_4_0_DEPRECATION
#if ST_DEPRECATED_VERSION >= 300
# define ST_DEPRECATED_IN_3_0(message) ST_DEPRECATED(message)
#else
# define ST_DEPRECATED_IN_3_0(message)
#endif
#if defined(ST_NO_4_0_DEPRECATION)
# define ST_DEPRECATED_IN_4_0(message)

#if ST_DEPRECATED_VERSION >= 304
# define ST_DEPRECATED_IN_3_4(message) ST_DEPRECATED(message)
#else
# define ST_DEPRECATED_IN_3_4(message)
#endif

#if ST_DEPRECATED_VERSION >= 400
# define ST_DEPRECATED_IN_4_0(message) ST_DEPRECATED(message)
#else
# define ST_DEPRECATED_IN_4_0(message)
#endif

#if defined(ST_HAVE_NODISCARD_ATTR)
Expand Down
14 changes: 7 additions & 7 deletions include/st_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace ST
public:
string() noexcept { }

ST_DEPRECATED_IN_4_0("Use empty initializer {} instead")
ST_DEPRECATED_IN_3_4("Use empty initializer {} instead")
string(const null_t &) noexcept { }

string(const char *cstr, size_t size = ST_AUTO_SIZE,
Expand Down Expand Up @@ -290,7 +290,7 @@ namespace ST
}
#endif

ST_DEPRECATED_IN_4_0("Use clear() instead")
ST_DEPRECATED_IN_3_4("Use clear() instead")
void set(const null_t &) noexcept { m_buffer.clear(); }

void set(const char *cstr, size_t size = ST_AUTO_SIZE,
Expand Down Expand Up @@ -513,7 +513,7 @@ namespace ST
m_buffer.clear();
}

ST_DEPRECATED_IN_4_0("Use clear() instead")
ST_DEPRECATED_IN_3_4("Use clear() instead")
string &operator=(const null_t &) noexcept
{
m_buffer.clear();
Expand Down Expand Up @@ -1632,7 +1632,7 @@ namespace ST
}

ST_NODISCARD
ST_DEPRECATED_IN_4_0("Use empty() instead")
ST_DEPRECATED_IN_3_4("Use empty() instead")
bool operator==(const null_t &) const noexcept
{
return empty();
Expand All @@ -1659,7 +1659,7 @@ namespace ST
#endif

ST_NODISCARD
ST_DEPRECATED_IN_4_0("Use !empty() instead")
ST_DEPRECATED_IN_3_4("Use !empty() instead")
bool operator!=(const null_t &) const noexcept
{
return !empty();
Expand Down Expand Up @@ -2651,14 +2651,14 @@ namespace ST
}

ST_NODISCARD
ST_DEPRECATED_IN_4_0("Use string::empty() instead")
ST_DEPRECATED_IN_3_4("Use string::empty() instead")
inline bool operator==(const null_t &, const string &right) noexcept
{
return right.empty();
}

ST_NODISCARD
ST_DEPRECATED_IN_4_0("Use !string::empty() instead")
ST_DEPRECATED_IN_3_4("Use !string::empty() instead")
inline bool operator!=(const null_t &, const string &right) noexcept
{
return !right.empty();
Expand Down

0 comments on commit 2dca62c

Please sign in to comment.