1 // Copyright Louis Dionne 2013-2017
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4 
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/string.hpp>
7 
8 #include <cstring>
9 namespace hana = boost::hana;
10 
11 
main()12 int main() {
13     BOOST_HANA_RUNTIME_CHECK(std::strcmp(
14         BOOST_HANA_STRING("").c_str(),
15         ""
16     ) == 0);
17 
18     BOOST_HANA_RUNTIME_CHECK(std::strcmp(
19         BOOST_HANA_STRING("a").c_str(),
20         "a"
21     ) == 0);
22 
23     BOOST_HANA_RUNTIME_CHECK(std::strcmp(
24         BOOST_HANA_STRING("ab").c_str(),
25         "ab"
26     ) == 0);
27 
28     BOOST_HANA_RUNTIME_CHECK(std::strcmp(
29         BOOST_HANA_STRING("abc").c_str(),
30         "abc"
31     ) == 0);
32 
33     BOOST_HANA_RUNTIME_CHECK(std::strcmp(
34         BOOST_HANA_STRING("abcd").c_str(),
35         "abcd"
36     ) == 0);
37 
38     // make sure we can turn a non-constexpr hana::string
39     // into a constexpr char const*
40     {
41         auto str = BOOST_HANA_STRING("abcdef");
42         constexpr char const* c_str = str.c_str();
43         (void)c_str;
44     }
45 
46     // make sure c_str is actually a static member function
47     {
48         constexpr char const* c_str = hana::string<'f', 'o', 'o'>::c_str();
49         (void)c_str;
50     }
51 }
52