/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#ifndef FOLLY_PADDED_H_
-#define FOLLY_PADDED_H_
+#pragma once
#include <algorithm>
#include <cassert>
lastCount_(lastCount) {
}
explicit Adaptor(size_t n, const value_type& value = value_type())
- : c_(Node::nodeCount(n), fullNode(value)),
- lastCount_(n % Node::kElementCount ?: Node::kElementCount) {
+ : c_(Node::nodeCount(n), fullNode(value)) {
+ const auto count = n % Node::kElementCount;
+ lastCount_ = count != 0 ? count : Node::kElementCount;
}
Adaptor(const Adaptor&) = default;
iterator end() {
auto it = iterator(c_.end());
if (lastCount_ != Node::kElementCount) {
- it -= (Node::kElementCount - lastCount_);
+ it -= difference_type(Node::kElementCount - lastCount_);
}
return it;
}
} // namespace padded
} // namespace folly
-
-#endif /* FOLLY_PADDED_H_ */