Skip to content

Commit

Permalink
fixes for VS2017 (closes #55)
Browse files Browse the repository at this point in the history
  • Loading branch information
marzer committed Aug 26, 2020
1 parent 83b9ca3 commit 977cfbb
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 54 deletions.
1 change: 1 addition & 0 deletions include/toml++/toml.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ TOML_POP_WARNINGS // TOML_DISABLE_SPAM_WARNINGS
#undef TOML_FLOAT_CHARCONV
#undef TOML_FP16
#undef TOML_GCC
#undef TOML_HAS_ATTR
#undef TOML_HAS_CUSTOM_OPTIONAL_TYPE
#undef TOML_HAS_INCLUDE
#undef TOML_ICC
Expand Down
21 changes: 10 additions & 11 deletions include/toml++/toml_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,61 +92,61 @@ TOML_IMPL_NAMESPACE_START
}

[[nodiscard]]
friend constexpr array_iterator operator + (const array_iterator& lhs, ptrdiff_t rhs) noexcept
friend array_iterator operator + (const array_iterator& lhs, ptrdiff_t rhs) noexcept
{
return { lhs.raw_ + rhs };
}

[[nodiscard]]
friend constexpr array_iterator operator + (ptrdiff_t lhs, const array_iterator& rhs) noexcept
friend array_iterator operator + (ptrdiff_t lhs, const array_iterator& rhs) noexcept
{
return { rhs.raw_ + lhs };
}

[[nodiscard]]
friend constexpr array_iterator operator - (const array_iterator& lhs, ptrdiff_t rhs) noexcept
friend array_iterator operator - (const array_iterator& lhs, ptrdiff_t rhs) noexcept
{
return { lhs.raw_ - rhs };
}

[[nodiscard]]
friend constexpr ptrdiff_t operator - (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend ptrdiff_t operator - (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ - rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator == (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator == (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ == rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator != (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator != (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ != rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator < (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator < (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ < rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator <= (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator <= (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ <= rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator > (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator > (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ > rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator >= (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator >= (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ >= rhs.raw_;
}
Expand All @@ -160,7 +160,6 @@ TOML_IMPL_NAMESPACE_START
TOML_DISABLE_WARNINGS

template <bool C = IsConst, typename = std::enable_if_t<!C>>
[[nodiscard]]
operator array_iterator<true>() const noexcept
{
return array_iterator<true>{ raw_ };
Expand Down
25 changes: 12 additions & 13 deletions include/toml++/toml_preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@
#define TOML_TRIVIAL_ABI __attribute__((__trivial_abi__))
#endif
#endif
#ifndef __EXCEPTIONS
#define TOML_COMPILER_EXCEPTIONS 0
#endif
#define TOML_LIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 1) )
#define TOML_UNLIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 0) )

Expand Down Expand Up @@ -138,9 +135,6 @@
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
#define TOML_RELOPS_REORDERING 1
#endif
#ifndef _CPPUNWIND
#define TOML_COMPILER_EXCEPTIONS 0
#endif

#endif // msvc

Expand Down Expand Up @@ -205,9 +199,6 @@
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
#define TOML_RELOPS_REORDERING 1
#endif
#ifndef __cpp_exceptions
#define TOML_COMPILER_EXCEPTIONS 0
#endif
#define TOML_LIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 1) )
#define TOML_UNLIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 0) )

Expand Down Expand Up @@ -319,8 +310,10 @@ is no longer necessary.
#define TOML_HAS_INCLUDE(header) 0
#endif

#ifndef TOML_COMPILER_EXCEPTIONS
#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) || defined(__cpp_exceptions)
#define TOML_COMPILER_EXCEPTIONS 1
#else
#define TOML_COMPILER_EXCEPTIONS 0
#endif
#if TOML_COMPILER_EXCEPTIONS
#if !defined(TOML_EXCEPTIONS) || (defined(TOML_EXCEPTIONS) && TOML_EXCEPTIONS)
Expand Down Expand Up @@ -414,14 +407,20 @@ is no longer necessary.
#define TOML_CONSTEVAL constexpr
#endif

#ifdef __has_cpp_attribute
#define TOML_HAS_ATTR(...) __has_cpp_attribute(__VA_ARGS__)
#else
#define TOML_HAS_ATTR(...) 0
#endif

#if !defined(DOXYGEN) && !TOML_INTELLISENSE
#if !defined(TOML_LIKELY) && __has_cpp_attribute(likely)
#if !defined(TOML_LIKELY) && TOML_HAS_ATTR(likely)
#define TOML_LIKELY(...) (__VA_ARGS__) [[likely]]
#endif
#if !defined(TOML_UNLIKELY) && __has_cpp_attribute(unlikely)
#if !defined(TOML_UNLIKELY) && TOML_HAS_ATTR(unlikely)
#define TOML_UNLIKELY(...) (__VA_ARGS__) [[unlikely]]
#endif
#if __has_cpp_attribute(nodiscard) >= 201907L
#if TOML_HAS_ATTR(nodiscard) >= 201907L
#define TOML_NODISCARD_CTOR [[nodiscard]]
#endif
#endif
Expand Down
5 changes: 2 additions & 3 deletions include/toml++/toml_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,20 @@ TOML_IMPL_NAMESPACE_START
}

[[nodiscard]]
friend constexpr bool operator == (const table_iterator& lhs, const table_iterator& rhs) noexcept
friend bool operator == (const table_iterator& lhs, const table_iterator& rhs) noexcept
{
return lhs.raw_ == rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator != (const table_iterator& lhs, const table_iterator& rhs) noexcept
friend bool operator != (const table_iterator& lhs, const table_iterator& rhs) noexcept
{
return lhs.raw_ != rhs.raw_;
}

TOML_DISABLE_WARNINGS

template <bool C = IsConst, typename = std::enable_if_t<!C>>
[[nodiscard]]
operator table_iterator<true>() const noexcept
{
return table_iterator<true>{ raw_ };
Expand Down
52 changes: 25 additions & 27 deletions toml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@
#define TOML_TRIVIAL_ABI __attribute__((__trivial_abi__))
#endif
#endif
#ifndef __EXCEPTIONS
#define TOML_COMPILER_EXCEPTIONS 0
#endif
#define TOML_LIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 1) )
#define TOML_UNLIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 0) )

Expand Down Expand Up @@ -167,9 +164,6 @@
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
#define TOML_RELOPS_REORDERING 1
#endif
#ifndef _CPPUNWIND
#define TOML_COMPILER_EXCEPTIONS 0
#endif

#endif // msvc

Expand Down Expand Up @@ -226,9 +220,6 @@
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
#define TOML_RELOPS_REORDERING 1
#endif
#ifndef __cpp_exceptions
#define TOML_COMPILER_EXCEPTIONS 0
#endif
#define TOML_LIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 1) )
#define TOML_UNLIKELY(...) (__builtin_expect(!!(__VA_ARGS__), 0) )

Expand Down Expand Up @@ -332,8 +323,10 @@ is no longer necessary.
#define TOML_HAS_INCLUDE(header) 0
#endif

#ifndef TOML_COMPILER_EXCEPTIONS
#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) || defined(__cpp_exceptions)
#define TOML_COMPILER_EXCEPTIONS 1
#else
#define TOML_COMPILER_EXCEPTIONS 0
#endif
#if TOML_COMPILER_EXCEPTIONS
#if !defined(TOML_EXCEPTIONS) || (defined(TOML_EXCEPTIONS) && TOML_EXCEPTIONS)
Expand Down Expand Up @@ -427,14 +420,20 @@ is no longer necessary.
#define TOML_CONSTEVAL constexpr
#endif

#ifdef __has_cpp_attribute
#define TOML_HAS_ATTR(...) __has_cpp_attribute(__VA_ARGS__)
#else
#define TOML_HAS_ATTR(...) 0
#endif

#if !defined(DOXYGEN) && !TOML_INTELLISENSE
#if !defined(TOML_LIKELY) && __has_cpp_attribute(likely)
#if !defined(TOML_LIKELY) && TOML_HAS_ATTR(likely)
#define TOML_LIKELY(...) (__VA_ARGS__) [[likely]]
#endif
#if !defined(TOML_UNLIKELY) && __has_cpp_attribute(unlikely)
#if !defined(TOML_UNLIKELY) && TOML_HAS_ATTR(unlikely)
#define TOML_UNLIKELY(...) (__VA_ARGS__) [[unlikely]]
#endif
#if __has_cpp_attribute(nodiscard) >= 201907L
#if TOML_HAS_ATTR(nodiscard) >= 201907L
#define TOML_NODISCARD_CTOR [[nodiscard]]
#endif
#endif
Expand Down Expand Up @@ -3342,61 +3341,61 @@ TOML_IMPL_NAMESPACE_START
}

[[nodiscard]]
friend constexpr array_iterator operator + (const array_iterator& lhs, ptrdiff_t rhs) noexcept
friend array_iterator operator + (const array_iterator& lhs, ptrdiff_t rhs) noexcept
{
return { lhs.raw_ + rhs };
}

[[nodiscard]]
friend constexpr array_iterator operator + (ptrdiff_t lhs, const array_iterator& rhs) noexcept
friend array_iterator operator + (ptrdiff_t lhs, const array_iterator& rhs) noexcept
{
return { rhs.raw_ + lhs };
}

[[nodiscard]]
friend constexpr array_iterator operator - (const array_iterator& lhs, ptrdiff_t rhs) noexcept
friend array_iterator operator - (const array_iterator& lhs, ptrdiff_t rhs) noexcept
{
return { lhs.raw_ - rhs };
}

[[nodiscard]]
friend constexpr ptrdiff_t operator - (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend ptrdiff_t operator - (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ - rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator == (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator == (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ == rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator != (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator != (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ != rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator < (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator < (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ < rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator <= (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator <= (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ <= rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator > (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator > (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ > rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator >= (const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator >= (const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.raw_ >= rhs.raw_;
}
Expand All @@ -3410,7 +3409,6 @@ TOML_IMPL_NAMESPACE_START
TOML_DISABLE_WARNINGS

template <bool C = IsConst, typename = std::enable_if_t<!C>>
[[nodiscard]]
operator array_iterator<true>() const noexcept
{
return array_iterator<true>{ raw_ };
Expand Down Expand Up @@ -3931,21 +3929,20 @@ TOML_IMPL_NAMESPACE_START
}

[[nodiscard]]
friend constexpr bool operator == (const table_iterator& lhs, const table_iterator& rhs) noexcept
friend bool operator == (const table_iterator& lhs, const table_iterator& rhs) noexcept
{
return lhs.raw_ == rhs.raw_;
}

[[nodiscard]]
friend constexpr bool operator != (const table_iterator& lhs, const table_iterator& rhs) noexcept
friend bool operator != (const table_iterator& lhs, const table_iterator& rhs) noexcept
{
return lhs.raw_ != rhs.raw_;
}

TOML_DISABLE_WARNINGS

template <bool C = IsConst, typename = std::enable_if_t<!C>>
[[nodiscard]]
operator table_iterator<true>() const noexcept
{
return table_iterator<true>{ raw_ };
Expand Down Expand Up @@ -11687,6 +11684,7 @@ TOML_POP_WARNINGS // TOML_DISABLE_SPAM_WARNINGS
#undef TOML_FLOAT_CHARCONV
#undef TOML_FP16
#undef TOML_GCC
#undef TOML_HAS_ATTR
#undef TOML_HAS_CUSTOM_OPTIONAL_TYPE
#undef TOML_HAS_INCLUDE
#undef TOML_ICC
Expand Down

0 comments on commit 977cfbb

Please sign in to comment.