Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/python/test/string_literal.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.6 KB
Line 
1// Copyright David Abrahams 2004. Distributed under the Boost
2// Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4#include <boost/python/detail/string_literal.hpp>
5//#include <stdio.h>
6#include <cassert>
7#include <boost/static_assert.hpp>
8
9using namespace boost::python::detail;
10   
11
12template <class T>
13void expect_string_literal(T const&)
14{
15    BOOST_STATIC_ASSERT(is_string_literal<T const>::value);
16}
17
18int main()
19{
20    expect_string_literal("hello");
21    BOOST_STATIC_ASSERT(!is_string_literal<int*&>::value);
22    BOOST_STATIC_ASSERT(!is_string_literal<int* const&>::value);
23    BOOST_STATIC_ASSERT(!is_string_literal<int*volatile&>::value);
24    BOOST_STATIC_ASSERT(!is_string_literal<int*const volatile&>::value);
25   
26    BOOST_STATIC_ASSERT(!is_string_literal<char const*>::value);
27    BOOST_STATIC_ASSERT(!is_string_literal<char*>::value);
28    BOOST_STATIC_ASSERT(!is_string_literal<char*&>::value);
29    BOOST_STATIC_ASSERT(!is_string_literal<char* const&>::value);
30    BOOST_STATIC_ASSERT(!is_string_literal<char*volatile&>::value);
31    BOOST_STATIC_ASSERT(!is_string_literal<char*const volatile&>::value);
32   
33    BOOST_STATIC_ASSERT(!is_string_literal<char[20]>::value);
34    BOOST_STATIC_ASSERT(is_string_literal<char const[20]>::value);
35    BOOST_STATIC_ASSERT(is_string_literal<char const[3]>::value);
36
37    BOOST_STATIC_ASSERT(!is_string_literal<int[20]>::value);
38    BOOST_STATIC_ASSERT(!is_string_literal<int const[20]>::value);
39    BOOST_STATIC_ASSERT(!is_string_literal<int const[3]>::value);
40    return 0;
41}
Note: See TracBrowser for help on using the repository browser.