Skip to content

Commit

Permalink
Change requires to use a default template argument (nonstd-lite-proje…
Browse files Browse the repository at this point in the history
…ct 40)

Fixes implementation of type_REQUIRES_T(), see martinmoene/nonstd-lite-project#40
  • Loading branch information
martinmoene committed Mar 6, 2020
1 parent 35c6077 commit 9b9af15
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions include/nonstd/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
template< bool B = (__VA_ARGS__), typename std::enable_if<B, int>::type = 0 >

#define type_REQUIRES_T(...) \
, typename = typename std::enable_if< (__VA_ARGS__), nonstd::types::detail::enabler >::type
, typename std::enable_if< (__VA_ARGS__), int >::type = 0

#define type_REQUIRES_R(R, ...) \
typename std::enable_if< (__VA_ARGS__), R>::type
Expand Down Expand Up @@ -243,13 +243,6 @@
*/
namespace nonstd { namespace types {

namespace detail {

#if type_CPP11_OR_GREATER
enum class enabler{};
#endif
}

// EqualityComparable, comparison functions based on operator==() and operator<():

template< typename T, typename U = T > struct is_eq { friend type_constexpr14 bool operator==( T const & x, U const & y ) { return x.get() == y.get(); } };
Expand Down Expand Up @@ -750,11 +743,14 @@ to_value( type<T,Tag,D> const & v )

namespace std {

template< typename Key >
struct hash;

template< typename T, typename Tag, typename D >
struct hash< nonstd::types::type<T,Tag,D> >
struct hash< ::nonstd::types::type<T,Tag,D> >
{
public:
std::size_t operator()( nonstd::types::type<T,Tag,D> const & v ) const type_noexcept
std::size_t operator()( ::nonstd::types::type<T,Tag,D> const & v ) const type_noexcept
{
return std::hash<T>()( v.get() );
}
Expand All @@ -770,7 +766,7 @@ std::size_t make_hash( type<T,Tag,D> const & v ) type_noexcept
return std::hash<type<T,Tag,D>>()( v );
}

}}
}} // namespace nonstd::types

#endif // type_HAVE_STD_HASH

Expand Down

0 comments on commit 9b9af15

Please sign in to comment.