Lua exception handling test
[folly.git] / folly / Padded.h
index 50fb8d78a5c4583acb78ff504c9249a233a21eb3..ca499aad0f70ad0626f620c06aca676caa400ce9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 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.
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef FOLLY_PADDED_H_
-#define FOLLY_PADDED_H_
+#pragma once
 
 #include <algorithm>
 #include <cassert>
@@ -28,8 +27,8 @@
 
 #include <boost/iterator/iterator_adaptor.hpp>
 
-#include <folly/Portability.h>
 #include <folly/ContainerTraits.h>
+#include <folly/Portability.h>
 
 /**
  * Code that aids in storing data aligned on block (possibly cache-line)
@@ -346,8 +345,9 @@ class Adaptor {
       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;
@@ -385,7 +385,7 @@ class Adaptor {
   iterator end() {
     auto it = iterator(c_.end());
     if (lastCount_ != Node::kElementCount) {
-      it -= (Node::kElementCount - lastCount_);
+      it -= difference_type(Node::kElementCount - lastCount_);
     }
     return it;
   }
@@ -512,5 +512,3 @@ class Adaptor {
 
 }  // namespace padded
 }  // namespace folly
-
-#endif /* FOLLY_PADDED_H_ */