summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/python/test/string_literal.cpp
blob: 7a349d6c2649fd79a01a1c3763e747a50852d200 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright David Abrahams 2004. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/python/detail/string_literal.hpp>
//#include <stdio.h>

#include <boost/detail/lightweight_test.hpp>
#include <boost/static_assert.hpp>

using namespace boost::python::detail;
    

template <class T>
void expect_string_literal(T const&)
{
    BOOST_STATIC_ASSERT(is_string_literal<T const>::value);
}

int main()
{
    expect_string_literal("hello");
    BOOST_STATIC_ASSERT(!is_string_literal<int*&>::value);
    BOOST_STATIC_ASSERT(!is_string_literal<int* const&>::value);
    BOOST_STATIC_ASSERT(!is_string_literal<int*volatile&>::value);
    BOOST_STATIC_ASSERT(!is_string_literal<int*const volatile&>::value);
    
    BOOST_STATIC_ASSERT(!is_string_literal<char const*>::value);
    BOOST_STATIC_ASSERT(!is_string_literal<char*>::value);
    BOOST_STATIC_ASSERT(!is_string_literal<char*&>::value);
    BOOST_STATIC_ASSERT(!is_string_literal<char* const&>::value);
    BOOST_STATIC_ASSERT(!is_string_literal<char*volatile&>::value);
    BOOST_STATIC_ASSERT(!is_string_literal<char*const volatile&>::value);
    
    BOOST_STATIC_ASSERT(!is_string_literal<char[20]>::value);
    BOOST_STATIC_ASSERT(is_string_literal<char const[20]>::value);
    BOOST_STATIC_ASSERT(is_string_literal<char const[3]>::value);

    BOOST_STATIC_ASSERT(!is_string_literal<int[20]>::value);
    BOOST_STATIC_ASSERT(!is_string_literal<int const[20]>::value);
    BOOST_STATIC_ASSERT(!is_string_literal<int const[3]>::value);
    return boost::report_errors();
}