1// Unit test for boost::lexical_cast.
2//
3// See http://www.boost.org for most recent version, including documentation.
4//
5// Copyright Alexander Nasonov, 2007.
6// Copyright Antony Polukhin, 2023-2024.
7//
8// Distributed under the Boost
9// Software License, Version 1.0. (See accompanying file
10// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
11//
12// Test that Source can be non-copyable.
13
14#include <boost/lexical_cast.hpp>
15#include <boost/core/noncopyable.hpp>
16
17#include <boost/core/lightweight_test.hpp>
18
19class Noncopyable : private boost::noncopyable
20{
21public:
22 Noncopyable() {}
23};
24
25inline std::ostream &operator<<(std::ostream &out, const Noncopyable&)
26{
27 return out << "Noncopyable";
28}
29
30void test_noncopyable()
31{
32 Noncopyable x;
33 BOOST_TEST(boost::lexical_cast<std::string>(x) == "Noncopyable");
34}
35
36int main()
37{
38 test_noncopyable();
39 return boost::report_errors();
40}
41

source code of boost/libs/lexical_cast/test/noncopyable_test.cpp