Skip to content

Commit 60d933f

Browse files
committed
Added Clang nullability checks for basic_string methods
1 parent 20aa1ae commit 60d933f

File tree

3 files changed

+93
-76
lines changed

3 files changed

+93
-76
lines changed

doc/container.qbk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,9 +1459,10 @@ use [*Boost.Container]? There are several reasons for that:
14591459
* If available, uses C++17's utilities under the `__cpp_aligned_new` feature.
14601460
* Uses alternative aligned allocation functions (`posix_memalign`, `aligned_alloc`, `_aligned_malloc`...) otherwise.
14611461
* Implemented overaligned allocation support for `adaptive_pool`and `node_allocator`
1462-
* Updated `basic_string` to the latest standard API:
1462+
* Updated `basic_string`:
14631463
* Added missing `string_view` members and updated `operator[]` to be able to return the terminating null.
14641464
* Added C++20 `starts_with`/`ends_with` and C++23 `contains` overloads.
1465+
* Added Clang `nullability` checks for `basic_string` methods.
14651466
* Fixed bugs/issues:
14661467
* [@https://github.com/boostorg/container/issues/323 GitHub #323: ['"flat_tree::try_emplace UB"]].
14671468
* [@https://github.com/boostorg/container/issues/328 GitHub #328: ['"boost::container::deque stores a redundant copy of the allocator, increasing size"]].

include/boost/container/detail/workaround.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,18 @@ namespace boost {
252252
#define BOOST_CONTAINER_NOVTABLE
253253
#endif
254254

255+
#if defined(__has_feature)
256+
# if __has_feature(nullability)
257+
# define BOOST_CONTAINER_NONNULL_SUPPORTED
258+
# define BOOST_CONTAINER_NONNULL _Nonnull
259+
# define BOOST_CONTAINER_NULLABLE _Nullable
260+
# endif
261+
#endif
262+
263+
#if !defined(BOOST_CONTAINER_NONNULL_SUPPORTED)
264+
# define BOOST_CONTAINER_NONNULL
265+
# define BOOST_CONTAINER_NULLABLE
266+
# undef BOOST_CONTAINER_NONNULL_SUPPORTED
267+
#endif
268+
255269
#endif //#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP

0 commit comments

Comments
 (0)