Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Make the tests pass in c++20
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Feb 15, 2023
1 parent d0a55c5 commit 85c8aa5
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ struct async_resource {
int _val = 0;

_LIBCUDACXX_TEMPLATE(class Property)
(requires !cuda::property_with_value<Property> &&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const async_resource&, Property) noexcept {}
(requires (!cuda::property_with_value<Property>) && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const async_resource&, Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class Property)
(requires cuda::property_with_value<Property>&&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type
get_property(const async_resource& res, Property) noexcept {
(requires cuda::property_with_value<Property> && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type get_property(const async_resource& res, Property) noexcept {
return res._val;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,12 @@ struct resource {
int _val = 0;

_LIBCUDACXX_TEMPLATE(class Property)
(requires !cuda::property_with_value<Property> &&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource&, Property) noexcept {}
(requires (!cuda::property_with_value<Property>) && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource&, Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class Property)
(requires cuda::property_with_value<Property>&&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type
get_property(const resource& res, Property) noexcept {
(requires cuda::property_with_value<Property> && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type get_property(const resource& res, Property) noexcept {
return res._val;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// cuda::mr::async_resource_ref equality

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@ struct async_resource {
int _val = 0;

_LIBCUDACXX_TEMPLATE(class Property)
(requires !cuda::property_with_value<Property> &&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const async_resource&, Property) noexcept {}
(requires (!cuda::property_with_value<Property>) && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const async_resource&, Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class Property)
(requires cuda::property_with_value<Property>&&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type
get_property(const async_resource& res, Property) noexcept {
(requires cuda::property_with_value<Property> && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type get_property(const async_resource& res, Property) noexcept {
return res._val;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ struct async_resource_base {
bool operator!=(const async_resource_base& other) const { return false; }

_LIBCUDACXX_TEMPLATE(class Property)
(requires !cuda::property_with_value<Property> &&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const async_resource_base&, Property) noexcept {}
(requires (!cuda::property_with_value<Property>) && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const async_resource_base&, Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class Property)
(requires cuda::property_with_value<Property>&&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type
get_property(const async_resource_base& res, Property) noexcept {
(requires cuda::property_with_value<Property> && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type get_property(const async_resource_base& res, Property) noexcept {
return 42;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,12 @@ struct async_resource {
int _val = 0;

_LIBCUDACXX_TEMPLATE(class Property)
(requires !cuda::property_with_value<Property> &&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const async_resource&, Property) noexcept {}
(requires (!cuda::property_with_value<Property>) && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const async_resource&, Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class Property)
(requires cuda::property_with_value<Property>&&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type
get_property(const async_resource& res, Property) noexcept {
(requires cuda::property_with_value<Property> && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type get_property(const async_resource& res, Property) noexcept {
return res._val;
}
};
Expand All @@ -89,25 +86,25 @@ static_assert(
(2 * sizeof(void*)));

_LIBCUDACXX_TEMPLATE(class Property, class Ref)
(requires !cuda::property_with_value<Property>) //
(requires (!cuda::property_with_value<Property>)) //
int InvokeIfWithValue(const Ref& ref) {
return -1;
}

_LIBCUDACXX_TEMPLATE(class Property, class Ref)
(requires cuda::property_with_value<Property>) //
(requires cuda::property_with_value<Property>) //
typename Property::value_type InvokeIfWithValue(const Ref& ref) {
return get_property(ref, Property{});
}

_LIBCUDACXX_TEMPLATE(class Property, class Ref)
(requires cuda::property_with_value<Property>) //
(requires cuda::property_with_value<Property>) //
int InvokeIfWithoutValue(const Ref& ref) {
return -1;
}

_LIBCUDACXX_TEMPLATE(class Property, class Ref)
(requires !cuda::property_with_value<Property>) //
(requires (!cuda::property_with_value<Property>)) //
int InvokeIfWithoutValue(const Ref& ref) {
get_property(ref, Property{});
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@ struct resource {
int _val = 0;

_LIBCUDACXX_TEMPLATE(class Property)
(requires !cuda::property_with_value<Property> &&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource&, Property) noexcept {}
(requires (!cuda::property_with_value<Property>) && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource&, Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class Property)
(requires cuda::property_with_value<Property>&&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type
get_property(const resource& res, Property) noexcept {
(requires cuda::property_with_value<Property> && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type get_property(const resource& res, Property) noexcept {
return res._val;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,12 @@ struct resource {
int _val = 0;

_LIBCUDACXX_TEMPLATE(class Property)
(requires !cuda::property_with_value<Property> &&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource&, Property) noexcept {}
(requires (!cuda::property_with_value<Property>) && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource&, Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class Property)
(requires cuda::property_with_value<Property>&&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type
get_property(const resource& res, Property) noexcept {
(requires cuda::property_with_value<Property> && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type get_property(const resource& res, Property) noexcept {
return res._val;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// cuda::mr::resource_ref equality

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ struct resource {
int _val = 0;

_LIBCUDACXX_TEMPLATE(class Property)
(requires !cuda::property_with_value<Property> &&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource&, Property) noexcept {}
(requires (!cuda::property_with_value<Property>) && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource&, Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class Property)
(requires cuda::property_with_value<Property>&&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type
get_property(const resource& res, Property) noexcept {
(requires cuda::property_with_value<Property> && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type get_property(const resource& res, Property) noexcept {
return res._val;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,12 @@ struct resource_base {
bool operator!=(const resource_base& other) const { return false; }

_LIBCUDACXX_TEMPLATE(class Property)
(requires !cuda::property_with_value<Property> &&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource_base&, Property) noexcept {}
(requires (!cuda::property_with_value<Property>) && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource_base&, Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class Property)
(requires cuda::property_with_value<Property>&&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type
get_property(const resource_base& res, Property) noexcept {
(requires cuda::property_with_value<Property> && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type get_property(const resource_base& res, Property) noexcept {
return 42;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ struct resource {
int _val = 0;

_LIBCUDACXX_TEMPLATE(class Property)
(requires !cuda::property_with_value<Property> &&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource&, Property) noexcept {}
(requires (!cuda::property_with_value<Property>) && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend void get_property(const resource&, Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class Property)
(requires cuda::property_with_value<Property>&&
_CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type
get_property(const resource& res, Property) noexcept {
(requires cuda::property_with_value<Property> && _CUDA_VSTD::_One_of<Property, Properties...>) //
friend typename Property::value_type get_property(const resource& res, Property) noexcept {
return res._val;
}
};
Expand All @@ -78,25 +75,25 @@ static_assert(sizeof(cuda::mr::resource_ref<property_without_value<short>,
(2 * sizeof(void*)));

_LIBCUDACXX_TEMPLATE(class Property, class Ref)
(requires !cuda::property_with_value<Property>) //
(requires (!cuda::property_with_value<Property>)) //
int InvokeIfWithValue(const Ref& ref) {
return -1;
}

_LIBCUDACXX_TEMPLATE(class Property, class Ref)
(requires cuda::property_with_value<Property>) //
(requires cuda::property_with_value<Property>) //
typename Property::value_type InvokeIfWithValue(const Ref& ref) {
return get_property(ref, Property{});
}

_LIBCUDACXX_TEMPLATE(class Property, class Ref)
(requires cuda::property_with_value<Property>) //
(requires cuda::property_with_value<Property>) //
int InvokeIfWithoutValue(const Ref& ref) {
return -1;
}

_LIBCUDACXX_TEMPLATE(class Property, class Ref)
(requires !cuda::property_with_value<Property>) //
(requires (!cuda::property_with_value<Property>)) //
int InvokeIfWithoutValue(const Ref& ref) {
get_property(ref, Property{});
return 1;
Expand Down
4 changes: 2 additions & 2 deletions include/cuda/memory_resource
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,11 @@ public:
}

_LIBCUDACXX_TEMPLATE(class _Property)
(requires !property_with_value<_Property> && _CUDA_VSTD::_One_of<_Property, _Properties...>) //
(requires (!property_with_value<_Property>) _LIBCUDACXX_AND _CUDA_VSTD::_One_of<_Property, _Properties...>) //
friend void get_property(const basic_resource_ref &, _Property) noexcept {}

_LIBCUDACXX_TEMPLATE(class _Property)
(requires property_with_value<_Property> &&_CUDA_VSTD::_One_of<_Property, _Properties...>) //
(requires property_with_value<_Property> _LIBCUDACXX_AND _CUDA_VSTD::_One_of<_Property, _Properties...>) //
friend __property_value_t<_Property> get_property(
const basic_resource_ref &__res, _Property) noexcept {
return __res._Property_vtable<_Property>::__property_fn(__res.__object);
Expand Down

0 comments on commit 85c8aa5

Please sign in to comment.