Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace default, constexpr, and delete macros by original keywords #360

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use default, constexpr, and delete directly instead of corresponding …
…macros

As part of #127, code for unsupported compilation modes/platforms will be removed.
`default`, `constexpr`, and `delete` are supported by all targeted compilers, so the conditional support can be removed.

All `_LIBCUDACXX_CONSTEXPR` macros are replaced by `constexpr`.
All `_LIBCUDACXX_EQUAL_DEFAULT` macros are replaced by `= default;`.
All `_LIBCUDACXX_EQUAL_DELETE` macros are replaced by `= delete;`.
  • Loading branch information
Martin Marenz committed Aug 22, 2023
commit 18ff1262f3031887d9d9cbd9e2fe0f29a40df9d8
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ public:
__bit_const_reference(const __bit_reference<_Cp>& __x) noexcept
: __seg_(__x.__seg_), __mask_(__x.__mask_) {}

_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR operator bool() const noexcept
_LIBCUDACXX_INLINE_VISIBILITY constexpr operator bool() const noexcept
{return static_cast<bool>(*__seg_ & __mask_);}

_LIBCUDACXX_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const noexcept
{return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
private:
_LIBCUDACXX_INLINE_VISIBILITY
_LIBCUDACXX_CONSTEXPR
constexpr
__bit_const_reference(__storage_pointer __s, __storage_type __m) noexcept
: __seg_(__s), __mask_(__m) {}

Expand Down
18 changes: 0 additions & 18 deletions libcudacxx/include/cuda/std/detail/libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -1546,24 +1546,6 @@ typedef unsigned int char32_t;
# define decltype(...) __decltype(__VA_ARGS__)
#endif // _LIBCUDACXX_CXX03_LANG

#ifdef _LIBCUDACXX_CXX03_LANG
# define _LIBCUDACXX_CONSTEXPR
#else
# define _LIBCUDACXX_CONSTEXPR constexpr
#endif

#ifdef _LIBCUDACXX_CXX03_LANG
# define _LIBCUDACXX_DEFAULT {}
#else
# define _LIBCUDACXX_DEFAULT = default;
#endif

#ifdef _LIBCUDACXX_CXX03_LANG
# define _LIBCUDACXX_EQUAL_DELETE
#else
# define _LIBCUDACXX_EQUAL_DELETE = delete
#endif

#if defined(_LIBCUDACXX_COMPILER_GCC) \
|| defined(_LIBCUDACXX_COMPILER_CLANG)
# define _LIBCUDACXX_NOALIAS __attribute__((__malloc__))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class barrier : public _CUDA_VSTD::__barrier_base<_CompletionF, _Sco> {
barrier(const barrier &) = delete;
barrier & operator=(const barrier &) = delete;

_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
_LIBCUDACXX_INLINE_VISIBILITY constexpr
barrier(_CUDA_VSTD::ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
: _CUDA_VSTD::__barrier_base<_CompletionF, _Sco>(__expected, __completion) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ _LIBCUDACXX_BEGIN_NAMESPACE_CUDA
template<thread_scope _Sco>
class latch : public _CUDA_VSTD::__latch_base<_Sco> {
public:
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
_LIBCUDACXX_INLINE_VISIBILITY constexpr
latch(_CUDA_VSTD::ptrdiff_t __count)
: _CUDA_VSTD::__latch_base<_Sco>(__count) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class counting_semaphore : public _CUDA_VSTD::__semaphore_base<__least_max_value
{
static_assert(__least_max_value <= _CUDA_VSTD::__semaphore_base<__least_max_value, _Sco>::max(), "");
public:
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
_LIBCUDACXX_INLINE_VISIBILITY constexpr
counting_semaphore(ptrdiff_t __count = 0) : _CUDA_VSTD::__semaphore_base<__least_max_value, _Sco>(__count) { }
~counting_semaphore() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ struct __policy
_LIBCUDACXX_INLINE_VISIBILITY
static const __policy* __create_empty()
{
static const _LIBCUDACXX_CONSTEXPR __policy __policy_ = {nullptr, nullptr,
static const constexpr __policy __policy_ = {nullptr, nullptr,
true,
#ifndef _LIBCUDACXX_NO_RTTI
&typeid(void)
Expand All @@ -638,7 +638,7 @@ struct __policy
template <typename _Fun>
_LIBCUDACXX_INLINE_VISIBILITY static const __policy*
__choose_policy(/* is_small = */ false_type) {
static const _LIBCUDACXX_CONSTEXPR __policy __policy_ = {
static const constexpr __policy __policy_ = {
&__large_clone<_Fun>, &__large_destroy<_Fun>, false,
#ifndef _LIBCUDACXX_NO_RTTI
&typeid(typename _Fun::_Target)
Expand All @@ -653,7 +653,7 @@ struct __policy
_LIBCUDACXX_INLINE_VISIBILITY static const __policy*
__choose_policy(/* is_small = */ true_type)
{
static const _LIBCUDACXX_CONSTEXPR __policy __policy_ = {
static const constexpr __policy __policy_ = {
nullptr, nullptr, false,
#ifndef _LIBCUDACXX_NO_RTTI
&typeid(typename _Fun::_Target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ _LIBCUDACXX_BEGIN_NAMESPACE_STD

struct __identity {
template <class _Tp>
_LIBCUDACXX_NODISCARD_EXT _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR _Tp&& operator()(_Tp&& __t) const noexcept {
_LIBCUDACXX_NODISCARD_EXT _LIBCUDACXX_INLINE_VISIBILITY constexpr _Tp&& operator()(_Tp&& __t) const noexcept {
return _CUDA_VSTD::forward<_Tp>(__t);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ _LIBCUDACXX_DISABLE_EXEC_CHECK
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet1<_Fp, _A0> >
inline _LIBCUDACXX_INLINE_VISIBILITY
_LIBCUDACXX_CONSTEXPR decltype((_CUDA_VSTD::declval<_A0>().*_CUDA_VSTD::declval<_Fp>())(_CUDA_VSTD::declval<_Args>()...))
constexpr decltype((_CUDA_VSTD::declval<_A0>().*_CUDA_VSTD::declval<_Fp>())(_CUDA_VSTD::declval<_Args>()...))
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
{ return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
Expand All @@ -351,7 +351,7 @@ _LIBCUDACXX_DISABLE_EXEC_CHECK
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet2<_Fp, _A0> >
inline _LIBCUDACXX_INLINE_VISIBILITY
_LIBCUDACXX_CONSTEXPR decltype((_CUDA_VSTD::declval<_A0>().get().*_CUDA_VSTD::declval<_Fp>())(_CUDA_VSTD::declval<_Args>()...))
constexpr decltype((_CUDA_VSTD::declval<_A0>().get().*_CUDA_VSTD::declval<_Fp>())(_CUDA_VSTD::declval<_Args>()...))
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
{ return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
Expand All @@ -360,7 +360,7 @@ _LIBCUDACXX_DISABLE_EXEC_CHECK
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet3<_Fp, _A0> >
inline _LIBCUDACXX_INLINE_VISIBILITY
_LIBCUDACXX_CONSTEXPR decltype(((*_CUDA_VSTD::declval<_A0>()).*_CUDA_VSTD::declval<_Fp>())(_CUDA_VSTD::declval<_Args>()...))
constexpr decltype(((*_CUDA_VSTD::declval<_A0>()).*_CUDA_VSTD::declval<_Fp>())(_CUDA_VSTD::declval<_Args>()...))
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
{ return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
Expand All @@ -371,7 +371,7 @@ _LIBCUDACXX_DISABLE_EXEC_CHECK
template <class _Fp, class _A0,
class = __enable_if_bullet4<_Fp, _A0> >
inline _LIBCUDACXX_INLINE_VISIBILITY
_LIBCUDACXX_CONSTEXPR decltype(_CUDA_VSTD::declval<_A0>().*_CUDA_VSTD::declval<_Fp>())
constexpr decltype(_CUDA_VSTD::declval<_A0>().*_CUDA_VSTD::declval<_Fp>())
__invoke(_Fp&& __f, _A0&& __a0)
noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
{ return static_cast<_A0&&>(__a0).*__f; }
Expand All @@ -380,7 +380,7 @@ _LIBCUDACXX_DISABLE_EXEC_CHECK
template <class _Fp, class _A0,
class = __enable_if_bullet5<_Fp, _A0> >
inline _LIBCUDACXX_INLINE_VISIBILITY
_LIBCUDACXX_CONSTEXPR decltype(_CUDA_VSTD::declval<_A0>().get().*_CUDA_VSTD::declval<_Fp>())
constexpr decltype(_CUDA_VSTD::declval<_A0>().get().*_CUDA_VSTD::declval<_Fp>())
__invoke(_Fp&& __f, _A0&& __a0)
noexcept(noexcept(__a0.get().*__f))
{ return __a0.get().*__f; }
Expand All @@ -389,7 +389,7 @@ _LIBCUDACXX_DISABLE_EXEC_CHECK
template <class _Fp, class _A0,
class = __enable_if_bullet6<_Fp, _A0> >
inline _LIBCUDACXX_INLINE_VISIBILITY
_LIBCUDACXX_CONSTEXPR decltype((*_CUDA_VSTD::declval<_A0>()).*_CUDA_VSTD::declval<_Fp>())
constexpr decltype((*_CUDA_VSTD::declval<_A0>()).*_CUDA_VSTD::declval<_Fp>())
__invoke(_Fp&& __f, _A0&& __a0)
noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
{ return (*static_cast<_A0&&>(__a0)).*__f; }
Expand All @@ -399,7 +399,7 @@ __invoke(_Fp&& __f, _A0&& __a0)
_LIBCUDACXX_DISABLE_EXEC_CHECK
template <class _Fp, class ..._Args>
inline _LIBCUDACXX_INLINE_VISIBILITY
_LIBCUDACXX_CONSTEXPR decltype(_CUDA_VSTD::declval<_Fp>()(_CUDA_VSTD::declval<_Args>()...))
constexpr decltype(_CUDA_VSTD::declval<_Fp>()(_CUDA_VSTD::declval<_Args>()...))
__invoke(_Fp&& __f, _Args&& ...__args)
noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
{ return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ _LIBCUDACXX_SUPPRESS_DEPRECATED_POP
istream_type* __in_stream_;
_Tp __value_;
public:
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {}
_LIBCUDACXX_INLINE_VISIBILITY constexpr istream_iterator() : __in_stream_(0), __value_() {}
_LIBCUDACXX_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_CUDA_VSTD::addressof(__s))
{
if (!(*__in_stream_ >> __value_))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ _LIBCUDACXX_SUPPRESS_DEPRECATED_POP
return __sbuf_ == 0;
}
public:
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR istreambuf_iterator() noexcept : __sbuf_(0) {}
_LIBCUDACXX_INLINE_VISIBILITY constexpr istreambuf_iterator() noexcept : __sbuf_(0) {}
_LIBCUDACXX_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) noexcept
: __sbuf_(__s.rdbuf()) {}
_LIBCUDACXX_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class _LIBCUDACXX_TYPE_VIS locale::id

static int32_t __next_id;
public:
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR id() :__id_(0) {}
_LIBCUDACXX_INLINE_VISIBILITY constexpr id() :__id_(0) {}
private:
void __init();
void operator=(const id&); // = delete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ template <class _Pointer, class = void>
struct __to_address_helper;

template <class _Tp>
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
_LIBCUDACXX_INLINE_VISIBILITY constexpr
_Tp* __to_address(_Tp* __p) noexcept {
static_assert(!is_function<_Tp>::value, "_Tp is a function type");
return __p;
Expand Down Expand Up @@ -337,15 +337,15 @@ struct _IsFancyPointer {
template <class _Pointer, class = __enable_if_t<
_And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value
> >
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
_LIBCUDACXX_INLINE_VISIBILITY constexpr
__decay_t<decltype(__to_address_helper<_Pointer>::__call(declval<const _Pointer&>()))>
__to_address(const _Pointer& __p) noexcept {
return __to_address_helper<_Pointer>::__call(__p);
}

template <class _Pointer, class>
struct __to_address_helper {
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
_LIBCUDACXX_INLINE_VISIBILITY constexpr
static decltype(_CUDA_VSTD::__to_address(declval<const _Pointer&>().operator->()))
__call(const _Pointer& __p) noexcept {
return _CUDA_VSTD::__to_address(__p.operator->());
Expand All @@ -354,7 +354,7 @@ struct __to_address_helper {

template <class _Pointer>
struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))> {
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
_LIBCUDACXX_INLINE_VISIBILITY constexpr
static decltype(pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))
__call(const _Pointer& __p) noexcept {
return pointer_traits<_Pointer>::to_address(__p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class _LIBCUDACXX_TYPE_VIS _LIBCUDACXX_THREAD_SAFETY_ANNOTATION(capability("mute

public:
_LIBCUDACXX_INLINE_VISIBILITY
_LIBCUDACXX_CONSTEXPR mutex() = default;
constexpr mutex() = default;

mutex(const mutex&) = delete;
mutex& operator=(const mutex&) = delete;
Expand Down Expand Up @@ -106,8 +106,8 @@ public:
~lock_guard() _LIBCUDACXX_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();}

private:
lock_guard(lock_guard const&) _LIBCUDACXX_EQUAL_DELETE;
lock_guard& operator=(lock_guard const&) _LIBCUDACXX_EQUAL_DELETE;
lock_guard(lock_guard const&) = delete;
lock_guard& operator=(lock_guard const&) = delete;
};

template <class _Mutex>
Expand Down Expand Up @@ -287,7 +287,7 @@ class _LIBCUDACXX_TYPE_VIS condition_variable
__libcpp_condvar_t __cv_ = _LIBCUDACXX_CONDVAR_INITIALIZER;
public:
_LIBCUDACXX_INLINE_VISIBILITY
_LIBCUDACXX_CONSTEXPR condition_variable() noexcept = default;
constexpr condition_variable() noexcept = default;

#ifdef _LIBCUDACXX_HAS_TRIVIAL_CONDVAR_DESTRUCTION
~condition_variable() = default;
Expand Down
14 changes: 7 additions & 7 deletions libcudacxx/include/cuda/std/detail/libcxx/include/__nullptr
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ struct _LIBCUDACXX_TEMPLATE_VIS nullptr_t

struct __nat {int __for_bool_;};

_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR nullptr_t() : __lx(0) {}
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {}
_LIBCUDACXX_INLINE_VISIBILITY constexpr nullptr_t() : __lx(0) {}
_LIBCUDACXX_INLINE_VISIBILITY constexpr nullptr_t(int __nat::*) : __lx(0) {}

_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR operator int __nat::*() const {return 0;}
_LIBCUDACXX_INLINE_VISIBILITY constexpr operator int __nat::*() const {return 0;}

template <class _Tp>
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR
_LIBCUDACXX_INLINE_VISIBILITY constexpr
operator _Tp* () const {return 0;}

template <class _Tp, class _Up>
_LIBCUDACXX_INLINE_VISIBILITY
operator _Tp _Up::* () const {return 0;}

friend _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
friend _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
friend _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator==(nullptr_t, nullptr_t) {return true;}
friend _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator!=(nullptr_t, nullptr_t) {return false;}
};

inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}
inline _LIBCUDACXX_INLINE_VISIBILITY constexpr nullptr_t __get_nullptr_t() {return nullptr_t(0);}

#define nullptr _CUDA_VSTD::__get_nullptr_t()

Expand Down
Loading