Implicit construct sorted_vector_set from std::initializer_list
authorQinfan Wu <wqfish@fb.com>
Tue, 4 Oct 2016 20:58:10 +0000 (13:58 -0700)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Tue, 4 Oct 2016 21:08:47 +0000 (14:08 -0700)
Summary:
The following thrift file doesn't work:
  typedef set<i32> (cpp.template = "folly::sorted_vector_set") IntSet
  struct Test {
    1: map<i32, IntSet> m = {7: [1, 2]},
  }

The generated file looks like this:
  Test()
      : m(std::initializer_list<
          std::pair<const int32_t, folly::sorted_vector_set<int32_t>>>{
          {7, std::initializer_list<int32_t>{1, 2}}}) {}

Given that `std::set` allows implicit construction from `std::initializer_list`, it's probably okay to make `folly::sorted_vector_set` the same.

Reviewed By: ot

Differential Revision: D3968054

fbshipit-source-id: 978d59a7e545e44d603eeb9671815ac7f2c57342

folly/sorted_vector_types.h

index d60388690447ebc50ff045619934af8a8a5b4b66..6809dde7793fb1fa24f323eb67ff8b970681d78a 100644 (file)
@@ -216,7 +216,7 @@ public:
     insert(first, last);
   }
 
-  explicit sorted_vector_set(
+  /* implicit */ sorted_vector_set(
       std::initializer_list<value_type> list,
       const Compare& comp = Compare(),
       const Allocator& alloc = Allocator())