Commit 266ca3b2 authored by Henry Wang's avatar Henry Wang Committed by Facebook GitHub Bot

Fix compiler warnings in small_vector

Summary:
Fix a bug in small_vector reported as a warning via gcc.

```
folly/small_vector.h: In instantiation of 'constexpr const size_t folly::small_vector<short int, 10>::MaxInline':
folly/small_vector.h:1183:56:   required from 'class folly::small_vector<short int, 10>'
bits/stl_stack.h:134:47:   required from 'class std::stack<short int, folly::small_vector<short int, 10> >'
folly/small_vector.h:462:36: error: division 'sizeof (short int*) / sizeof (short int)' does not compute the number of array elements [-Werror=sizeof-pointer-div]
  462 |       constexpr_max(sizeof(Value*) / sizeof(Value), RequestedMaxInline)};
      |                     ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
```

Reviewed By: yfeldblum

Differential Revision: D27688663

fbshipit-source-id: 8da5b017c597c542826e26f2c36b0e3b46e87ed9
parent c8613fb4
......@@ -458,8 +458,10 @@ class small_vector : public detail::small_vector_base<
* the user asks for less inlined elements than we can fit unioned
* into our value_type*, we will inline more than they asked.)
*/
static constexpr auto kSizeOfValuePtr = sizeof(Value*);
static constexpr auto kSizeOfValue = sizeof(Value);
static constexpr std::size_t MaxInline{
constexpr_max(sizeof(Value*) / sizeof(Value), RequestedMaxInline)};
constexpr_max(kSizeOfValuePtr / kSizeOfValue, RequestedMaxInline)};
public:
typedef std::size_t size_type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment