[PATCH] [libcxx] Properly convert the count arguments to the *_n algorithms before use.

Eric Fiselier eric at efcs.ca
Thu Feb 5 14:57:50 PST 2015


Hi mclow.lists, chandlerc,

The requirement on the `Size` type passed to *_n algorithms is that it is convertible to an integral type. This means we can't use a variable of type `Size` directly. Instead we need to convert it to an integral type first.  The problem is finding out what integral type to convert it to.  `__convert_to_integral` figures out what integral type to convert it to and performs the conversion, It also promotes the resulting integral type so that it is at least as big as an integer. `__convert_to_integral` also has a special case for converting enums. This should only work on non-scoped enumerations because it does not apply an explicit conversion from the enum to its underlying type.

http://reviews.llvm.org/D7449

Files:
  include/algorithm
  include/type_traits
  test/libcxx/type_traits/convert_to_integral.pass.cpp
  test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
  test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
  test/std/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp
  test/std/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp
  test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7449.19435.patch
Type: text/x-patch
Size: 11839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150205/2760524b/attachment.bin>


More information about the cfe-commits mailing list