Ticket #3704: decay.cpp

File decay.cpp, 665 bytes (added by Kenneth Ho <ken@…>, 13 years ago)

Source code of test program to demonstrate the incorrectness of decay doc.

Line 
1#include <boost/type_traits.hpp>
2#include <boost/static_assert.hpp>
3
4using namespace boost;
5
6int main()
7{
8 static const size_t TopDim = 2;
9 static const size_t LowDim = 3;
10
11 typedef int ArrayTwoDim[TopDim][LowDim];
12 typedef int LowDimRemoved[TopDim];
13 typedef int TopDimRemoved[LowDim];
14
15 BOOST_STATIC_ASSERT((
16 is_same<
17 decay<ArrayTwoDim>::type,
18 TopDimRemoved*
19 >::value
20 ));
21
22 BOOST_STATIC_ASSERT((
23 is_same<
24 remove_extent<ArrayTwoDim>::type*,
25 decay<ArrayTwoDim>::type
26 >::value
27 ));
28
29 BOOST_STATIC_ASSERT((
30 is_same<
31 remove_extent<ArrayTwoDim>::type,
32 TopDimRemoved
33 >::value
34 ));
35
36 return 0;
37}
38