70 lines · cpp
1// RUN: rm -rf %t2// RUN: %clang_cc1 -x c++ -std=c++20 %s -verify -fmodules -fmodules-cache-path=%t3// expected-no-diagnostics4 5#pragma clang module build std6module std [system] {7 module concepts [system] {8 module assignable [system] {9 }10 export *11 }12 module functional [system] {13 export *14 }15 16 17 module type_traits [system] {18 export *19 }20}21 22#pragma clang module contents23#pragma clang module begin std.type_traits24namespace std {25template<class _Tp, class _Up>26concept same_as = __is_same(_Tp, _Up);27 28template <class...>29struct common_reference;30 31template <class _Tp, class _Up> struct common_reference<_Tp, _Up>32{33 using type = _Tp;34};35}36#pragma clang module end // type_traits37 38#pragma clang module begin std.concepts.assignable39#pragma clang module import std.type_traits40namespace std {41template<class _Tp, class _Up>42concept common_reference_with =43 same_as<typename common_reference<_Tp, _Up>::type, typename common_reference<_Up, _Tp>::type>;44}45namespace std {46template<class _Lhs, class _Rhs>47concept assignable_from =48 common_reference_with<const __remove_reference_t(_Lhs)&, const __remove_reference_t(_Rhs)&> ;49}50#pragma clang module end // std.concepts.assignable51 52#pragma clang module begin std.functional53#pragma clang module import std.concepts.assignable54namespace std {55template<class _Sp, class _Ip>56concept sentinel_for = assignable_from<_Ip&, _Ip>;57template <class _Sp, class _Ip>58concept nothrow_sentinel_for = sentinel_for<_Sp, _Ip>;59}60#pragma clang module end // std::functional61#pragma clang module endbuild // contents62 63 64#pragma clang module import std.functional65constexpr bool ntsf_subsumes_sf(std::nothrow_sentinel_for<char*> auto) requires true {66 return true;67}68constexpr bool ntsf_subsumes_sf(std::sentinel_for<char*> auto);69static_assert(ntsf_subsumes_sf("foo"));70