1/*
2Copyright 2023 Glen Joseph Fernandes
3(glenjofe@gmail.com)
4
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7*/
8#include <boost/config.hpp>
9#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
10#include <boost/core/data.hpp>
11#include <boost/core/lightweight_test.hpp>
12
13class range {
14public:
15 int* data() {
16 return &v_[0];
17 }
18
19 const int* data() const {
20 return &v_[0];
21 }
22
23 std::size_t size() const {
24 return 4;
25 }
26
27private:
28 int v_[4];
29};
30
31void test_range()
32{
33 range c;
34 BOOST_TEST_EQ(boost::data(c), c.data());
35}
36
37void test_const_range()
38{
39 const range c = range();
40 BOOST_TEST_EQ(boost::data(c), c.data());
41}
42
43void test_array()
44{
45 int a[4];
46 BOOST_TEST_EQ(boost::data(a), a);
47}
48
49void test_initializer_list()
50{
51 std::initializer_list<int> l{1, 2, 3, 4};
52 BOOST_TEST_EQ(boost::data(l), l.begin());
53}
54
55int main()
56{
57 test_range();
58 test_const_range();
59 test_array();
60 test_initializer_list();
61 return boost::report_errors();
62}
63#else
64int main()
65{
66 return 0;
67}
68#endif
69

source code of boost/libs/core/test/data_test.cpp