]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright David Abrahams 2002. |
2 | // Distributed under the Boost Software License, Version 1.0. (See | |
3 | // accompanying file LICENSE_1_0.txt or copy at | |
4 | // http://www.boost.org/LICENSE_1_0.txt) | |
5 | #include <boost/static_assert.hpp> | |
6 | #include <boost/python/detail/if_else.hpp> | |
b32b8144 | 7 | #include <boost/python/detail/type_traits.hpp> |
7c673cae FG |
8 | |
9 | typedef char c1; | |
10 | typedef char c2[2]; | |
11 | typedef char c3[3]; | |
12 | typedef char c4[4]; | |
13 | ||
14 | template <unsigned size> | |
15 | struct choose | |
16 | { | |
17 | typedef typename boost::python::detail::if_< | |
18 | (sizeof(c1) == size) | |
19 | >::template then< | |
20 | c1 | |
21 | >::template elif< | |
22 | (sizeof(c2) == size) | |
23 | >::template then< | |
24 | c2 | |
25 | >::template elif< | |
26 | (sizeof(c3) == size) | |
27 | >::template then< | |
28 | c3 | |
29 | >::template elif< | |
30 | (sizeof(c4) == size) | |
31 | >::template then< | |
32 | c4 | |
33 | >::template else_<void*>::type type; | |
34 | }; | |
35 | ||
36 | int main() | |
37 | { | |
b32b8144 FG |
38 | BOOST_STATIC_ASSERT((boost::python::detail::is_same<choose<1>::type,c1>::value)); |
39 | BOOST_STATIC_ASSERT((boost::python::detail::is_same<choose<2>::type,c2>::value)); | |
40 | BOOST_STATIC_ASSERT((boost::python::detail::is_same<choose<3>::type,c3>::value)); | |
41 | BOOST_STATIC_ASSERT((boost::python::detail::is_same<choose<4>::type,c4>::value)); | |
42 | BOOST_STATIC_ASSERT((boost::python::detail::is_same<choose<5>::type,void*>::value)); | |
7c673cae FG |
43 | return 0; |
44 | } |