[llvm] r216821 - Add a test for converting ArrayRef<T *> to ArrayRef<const T *>.
David Blaikie
dblaikie at gmail.com
Sat Aug 30 18:44:24 PDT 2014
On Sat, Aug 30, 2014 at 10:21 AM, Craig Topper <craig.topper at gmail.com>
wrote:
> I suspect you'd know better than me. This constructor was my first real
> experience with type traits.
>
Added a few in r216830 - I think this generally captures the idea. Are
there any other conversions, apart from adding cv qualifiers, that we
should expect this to allow?
>
>
> On Sat, Aug 30, 2014 at 10:13 AM, David Blaikie <dblaikie at gmail.com>
> wrote:
>
>>
>>
>>
>> On Sat, Aug 30, 2014 at 9:48 AM, Craig Topper <craig.topper at gmail.com>
>> wrote:
>>
>>> Author: ctopper
>>> Date: Sat Aug 30 11:48:19 2014
>>> New Revision: 216821
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=216821&view=rev
>>> Log:
>>> Add a test for converting ArrayRef<T *> to ArrayRef<const T *>.
>>>
>>
>> Could we use some static_asserts with type traits to check that other
>> things /aren't/ convertible?
>>
>>
>>>
>>> Modified:
>>> llvm/trunk/unittests/ADT/ArrayRefTest.cpp
>>>
>>> Modified: llvm/trunk/unittests/ADT/ArrayRefTest.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/ArrayRefTest.cpp?rev=216821&r1=216820&r2=216821&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/unittests/ADT/ArrayRefTest.cpp (original)
>>> +++ llvm/trunk/unittests/ADT/ArrayRefTest.cpp Sat Aug 30 11:48:19 2014
>>> @@ -63,4 +63,14 @@ TEST(ArrayRefTest, EmptyEquals) {
>>> EXPECT_TRUE(ArrayRef<unsigned>() == ArrayRef<unsigned>());
>>> }
>>>
>>> +TEST(ArrayRefTest, ConstConvert) {
>>> + int buf[4];
>>> + for (int i = 0; i < 4; ++i)
>>> + buf[i] = i;
>>> +
>>> + static int *A[] = {&buf[0], &buf[1], &buf[2], &buf[3]};
>>> + ArrayRef<const int *> a((ArrayRef<int *>(A)));
>>> + a = ArrayRef<int *>(A);
>>> +}
>>> +
>>> } // end anonymous namespace
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>
>>
>
>
> --
> ~Craig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140830/945ebd29/attachment.html>
More information about the llvm-commits
mailing list