Skip to content

Commit

Permalink
Removed C++14 feature macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Oct 19, 2019
1 parent 0c04d26 commit 8becb29
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 79 deletions.
34 changes: 1 addition & 33 deletions src/config.hpp
Expand Up @@ -49,37 +49,13 @@
#include "config_attribute_value.hpp"
#include "exceptions.hpp"

#ifdef HAVE_CXX14
# ifdef __clang__ // Check this first, because clang also defines __GNUC__
# ifdef __apple_build_version__ // Apple clang
# if (__clang_major__ == 5 && __clang_minor__ >= 1) || __clang_major__ > 5 // Apple clang 5.1+
# define USE_HETEROGENOUS_LOOKUPS
# endif
# else // Non-Apple clang
# if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3 // clang 3.4+
# define USE_HETEROGENOUS_LOOKUPS
# endif
# endif
# elif defined(__GNUC__) && __GNUC__ >= 5 // GCC 5.0+
# define USE_HETEROGENOUS_LOOKUPS
# endif
#endif

#if defined(_MSC_VER) && _MSC_VER >= 1900 // MSVC 2015
# define USE_HETEROGENOUS_LOOKUPS
#endif

#ifdef USE_HETEROGENOUS_LOOKUPS
#if BOOST_VERSION > 106100
#include <boost/utility/string_view.hpp>
using config_key_type = boost::string_view;
#else
#include <boost/utility/string_ref.hpp>
using config_key_type = boost::string_ref;
#endif
#else
using config_key_type = const std::string &;
#endif

class config;
class enum_tag;
Expand Down Expand Up @@ -141,11 +117,7 @@ class config
{ return this != &invalid; }

typedef std::vector<std::unique_ptr<config>> child_list;
typedef std::map<std::string, child_list
#ifdef USE_HETEROGENOUS_LOOKUPS
, std::less<>
#endif
> child_map;
typedef std::map<std::string, child_list, std::less<>> child_map;

struct const_child_iterator;

Expand Down Expand Up @@ -249,9 +221,7 @@ class config
typedef std::map<
std::string
, attribute_value
#ifdef USE_HETEROGENOUS_LOOKUPS
, std::less<>
#endif
> attribute_map;
typedef attribute_map::value_type attribute;
struct const_attribute_iterator;
Expand Down Expand Up @@ -405,7 +375,6 @@ class config
*/
const attribute_value& operator[](config_key_type key) const;

#ifdef USE_HETEROGENOUS_LOOKUPS
/**
* Returns a reference to the attribute with the given @a key.
* Creates it if it does not exist.
Expand All @@ -423,7 +392,6 @@ class config
{
return operator[](config_key_type(key));
}
#endif

/**
* Returns a reference to the attribute with the given @a key.
Expand Down
20 changes: 0 additions & 20 deletions src/config_attribute_value.hpp
Expand Up @@ -47,26 +47,6 @@

#include "tstring.hpp"

#ifdef HAVE_CXX14
# ifdef __clang__ // Check this first, because clang also defines __GNUC__
# ifdef __apple_build_version__ // Apple clang
# if (__clang_major__ == 5 && __clang_minor__ >= 1) || __clang_major__ > 5 // Apple clang 5.1+
# define USE_HETEROGENOUS_LOOKUPS
# endif
# else // Non-Apple clang
# if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3 // clang 3.4+
# define USE_HETEROGENOUS_LOOKUPS
# endif
# endif
# elif defined(__GNUC__) && __GNUC__ >= 5 // GCC 5.0+
# define USE_HETEROGENOUS_LOOKUPS
# endif
#endif

#if defined(_MSC_VER) && _MSC_VER >= 1900 // MSVC 2015
# define USE_HETEROGENOUS_LOOKUPS
#endif

class enum_tag;

/**
Expand Down
24 changes: 9 additions & 15 deletions src/formatter.hpp
Expand Up @@ -38,38 +38,32 @@
class formatter
{
public:
formatter() :
stream_()
formatter()
: stream_()
{
}

template<typename T>
formatter& operator<<(const T & o)
#if HAVE_REF_QUALIFIERS
&
#endif
formatter& operator<<(const T& o) &
{
stream_ << o;
return *this;
}

#if HAVE_REF_QUALIFIERS
template <typename T>
formatter && operator<<(const T & o) && {
template<typename T>
formatter&& operator<<(const T& o) &&
{
stream_ << o;
return std::move(*this);
}
#endif

std::string str() const {
std::string str() const
{
return stream_.str();
}

// Implicit x-value conversion to string
operator std::string() const
#if HAVE_REF_QUALIFIERS
&&
#endif
operator std::string() const &&
{
return stream_.str();
}
Expand Down
12 changes: 1 addition & 11 deletions src/global.hpp
Expand Up @@ -33,20 +33,15 @@

#define UNUSED(x) ((void)(x)) /* to avoid warnings */

// To allow using some optional C++14 and C++17 features
#if __cplusplus >= 201402L
#define HAVE_CXX14
// To allow using some optional C++17 features
#if __cplusplus >= 201703L
#define HAVE_CXX17
#endif
#endif

// Some C++11 features are not available on all supported platforms
#if defined(_MSC_VER)
// MSVC supports these starting in MSVC 2015
#if _MSC_VER >= 1900
#define HAVE_REF_QUALIFIERS 1
#define HAVE_INHERITING_CTORS 1
#else
#endif
// MSVC supports these starting in 2017?
Expand All @@ -67,9 +62,6 @@
#if defined(__clang__)
#include <ciso646> // To ensure standard library version macros are defined

// Clang has convenient feature detection macros \o/
#define HAVE_REF_QUALIFIERS __has_feature(cxx_reference_qualified_functions)
#define HAVE_INHERITING_CTORS __has_feature(cxx_inheriting_constructors)
// All supported versions of clang have these
#define FALLTHROUGH [[clang::fallthrough]]
// Use GCC-style attribute because the __has_cpp_attribute feature-checking macro doesn't exist in clang 3.5
Expand All @@ -79,8 +71,6 @@

#if defined(__GNUC__) && !defined(__clang__)
// GCC supports these from 4.8 up
#define HAVE_REF_QUALIFIERS 1
#define HAVE_INHERITING_CTORS 1

// Deprecated is supported from 4.9 up
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
Expand Down

0 comments on commit 8becb29

Please sign in to comment.