ams: take care of most TODO C++20s

This commit is contained in:
Michael Scire
2020-05-05 19:53:38 -07:00
parent 13bfeed2d5
commit 232203f4c0
30 changed files with 174 additions and 431 deletions

View File

@@ -77,7 +77,7 @@ namespace ams::sf {
class Out<std::shared_ptr<ServiceImpl>> : public impl::OutObjectTag {
static_assert(std::is_base_of<sf::IServiceObject, ServiceImpl>::value, "Out<std::shared_ptr<ServiceImpl>> requires ServiceObject base.");
template<typename, typename>
template<typename>
friend class Out;
public:
@@ -308,11 +308,7 @@ namespace ams::sf::impl {
/* Use insertion sort, which is stable and optimal for small numbers of parameters. */
for (size_t i = 1; i < sizeof...(Ts); i++) {
for (size_t j = i; j > 0 && values[map[j-1]] > values[map[j]]; j--) {
/* std::swap is not constexpr until c++20 :( */
/* TODO: std::swap(map[j], map[j-1]); */
const size_t tmp = map[j];
map[j] = map[j-1];
map[j-1] = tmp;
std::swap(map[j], map[j-1]);
}
}
}

View File

@@ -33,9 +33,9 @@ namespace ams::sf {
struct IsOutForceEnabled<::ams::Result> : public std::true_type{};
template<typename T>
using IsOutEnabled = typename std::enable_if<std::is_trivial<T>::value || IsOutForceEnabled<T>::value>::type;
concept OutEnabled = (std::is_trivial<T>::value || IsOutForceEnabled<T>::value) && !std::is_pointer<T>::value;
template<typename T, typename = IsOutEnabled<T>>
template<typename T> requires OutEnabled<T>
class Out : public impl::OutBaseTag {
public:
static constexpr size_t TypeSize = sizeof(T);

View File

@@ -451,7 +451,7 @@ namespace ams::ncm {
/* Ensure this type of key has an owner. */
R_UNLESS(key.type == ContentMetaType::Application || key.type == ContentMetaType::Patch || key.type == ContentMetaType::AddOnContent, ncm::ResultInvalidContentMetaKey());
/* Applications are their own owner. */
if (key.type == ContentMetaType::Application) {
out_id.SetValue({key.id});

View File

@@ -18,7 +18,6 @@
namespace ams::os::impl {
/* TODO: C++20 constinit */
TYPED_STORAGE(OsResourceManager) ResourceManagerHolder::s_resource_manager_storage = {};
constinit TYPED_STORAGE(OsResourceManager) ResourceManagerHolder::s_resource_manager_storage = {};
}