Skip to content

Commit

Permalink
CPP 11 and 14 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzegorz Głowacki committed Apr 30, 2020
1 parent 6c37441 commit 04f4834
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions include/NamedType/named_type_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
# define IGNORE_SHOULD_RETURN_REFERENCE_TO_THIS_END /* Nothing */
#endif

#if defined(FLUENT_NODISCARD)
#error FLUENT_NODISCARD already defined
#endif

#if (__cplusplus >= 201703L) && !defined(_MSVC_LANG)
#if defined(__has_cpp_attribute) && (__has_cpp_attribute(nodiscard) >= 201603L)
#define FLUENT_NODISCARD [[nodiscard]]
#endif
#endif

#if defined(_MSVC_LANG) && (_MSVC_LANG>=201703L)
#define FLUENT_NODISCARD [[nodiscard]]
#endif

#if !defined(FLUENT_NODISCARD)
#define FLUENT_NODISCARD
#endif

namespace fluent
{

Expand Down Expand Up @@ -48,17 +66,6 @@ class FLUENT_EBCO NamedType : public Skills<NamedType<T, Parameter, Skills...>>.
{
}

// get
[[nodiscard]] constexpr T& get() noexcept
{
return value_;
}

[[nodiscard]] constexpr T const& get() const noexcept
{
return value_;
}

// conversions
using ref = NamedType<T&, Parameter, Skills...>;
operator ref()
Expand All @@ -85,6 +92,17 @@ class FLUENT_EBCO NamedType : public Skills<NamedType<T, Parameter, Skills...>>.
argument& operator=(argument&&) = delete;
};

// get
FLUENT_NODISCARD constexpr T& get() noexcept
{
return value_;
}

FLUENT_NODISCARD constexpr T const& get() const noexcept
{
return value_;
}

private:
T value_{};
};
Expand Down

0 comments on commit 04f4834

Please sign in to comment.