-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hidden friends for access and reverse access
- Loading branch information
Showing
11 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of libcu++, the C++ Standard Library for your entire system, | ||
// under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef __CCCL_SEQUENCE_ACCESS_H | ||
#define __CCCL_SEQUENCE_ACCESS_H | ||
|
||
#include <cuda/std/__cccl/compiler.h> | ||
#include <cuda/std/__cccl/system_header.h> | ||
|
||
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) | ||
# pragma GCC system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) | ||
# pragma clang system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) | ||
# pragma system_header | ||
#endif // no system header | ||
|
||
// We need to define hidden friends for {cr,r,}{begin,end} of our containers as we will otherwise encounter ambigouities | ||
#define _CCCL_SYNTHESIZE_SEQUENCE_ACCESS(_ClassName, _ConstIter) \ | ||
friend iterator begin(_ClassName& __sequence) noexcept(noexcept(__sequence.begin())) \ | ||
{ \ | ||
return __sequence.begin(); \ | ||
} \ | ||
friend _ConstIter begin(const _ClassName& __sequence) noexcept(noexcept(__sequence.begin())) \ | ||
{ \ | ||
return __sequence.begin(); \ | ||
} \ | ||
friend iterator end(_ClassName& __sequence) noexcept(noexcept(__sequence.end())) \ | ||
{ \ | ||
return __sequence.end(); \ | ||
} \ | ||
friend _ConstIter end(const _ClassName& __sequence) noexcept(noexcept(__sequence.end())) \ | ||
{ \ | ||
return __sequence.end(); \ | ||
} \ | ||
friend _ConstIter cbegin(const _ClassName& __sequence) noexcept(noexcept(__sequence.begin())) \ | ||
{ \ | ||
return __sequence.begin(); \ | ||
} \ | ||
friend _ConstIter cend(const _ClassName& __sequence) noexcept(noexcept(__sequence.end())) \ | ||
{ \ | ||
return __sequence.end(); \ | ||
} | ||
#define _CCCL_SYNTHESIZE_SEQUENCE_REVERSE_ACCESS(_ClassName, _ConstIter) \ | ||
friend reverse_iterator rbegin(_ClassName& __sequence) noexcept(noexcept(__sequence.rbegin())) \ | ||
{ \ | ||
return __sequence.rbegin(); \ | ||
} \ | ||
friend _ConstIter rbegin(const _ClassName& __sequence) noexcept(noexcept(__sequence.rbegin())) \ | ||
{ \ | ||
return __sequence.rbegin(); \ | ||
} \ | ||
friend reverse_iterator rend(_ClassName& __sequence) noexcept(noexcept(__sequence.rend())) \ | ||
{ \ | ||
return __sequence.rend(); \ | ||
} \ | ||
friend _ConstIter rend(const _ClassName& __sequence) noexcept(noexcept(__sequence.rend())) \ | ||
{ \ | ||
return __sequence.rend(); \ | ||
} \ | ||
friend _ConstIter crbegin(const _ClassName& __sequence) noexcept(noexcept(__sequence.rbegin())) \ | ||
{ \ | ||
return __sequence.rbegin(); \ | ||
} \ | ||
friend _ConstIter crend(const _ClassName& __sequence) noexcept(noexcept(__sequence.rend())) \ | ||
{ \ | ||
return __sequence.rend(); \ | ||
} | ||
|
||
#endif // __CCCL_SEQUENCE_ACCESS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters