• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  (C) Copyright Gennadiy Rozental 2001.
2 //  Distributed under the Boost Software License, Version 1.0.
3 //  (See accompanying file LICENSE_1_0.txt or copy at
4 //  http://www.boost.org/LICENSE_1_0.txt)
5 
6 //  See http://www.boost.org/libs/test for the library home page.
7 //
8 ///@file
9 ///Defines monomorphic dataset based on C type arrays
10 // ***************************************************************************
11 
12 #ifndef BOOST_TEST_DATA_MONOMORPHIC_ARRAY_HPP_121411GER
13 #define BOOST_TEST_DATA_MONOMORPHIC_ARRAY_HPP_121411GER
14 
15 // Boost.Test
16 #include <boost/test/data/config.hpp>
17 #include <boost/test/data/monomorphic/fwd.hpp>
18 
19 #include <boost/test/detail/suppress_warnings.hpp>
20 
21 //____________________________________________________________________________//
22 
23 namespace boost {
24 namespace unit_test {
25 namespace data {
26 namespace monomorphic {
27 
28 // ************************************************************************** //
29 // **************                     array                    ************** //
30 // ************************************************************************** //
31 
32 /// Dataset view of a C array
33 template<typename T>
34 class array {
35 public:
36     typedef T sample;
37 
38     enum { arity = 1 };
39 
40     typedef T const* iterator;
41 
42     // Constructor
array(T const * arr_,std::size_t size_)43     array( T const* arr_, std::size_t size_ )
44     : m_arr( arr_ )
45     , m_size( size_ )
46     {}
47 
48     // dataset interface
size() const49     data::size_t    size() const    { return m_size; }
begin() const50     iterator        begin() const   { return m_arr; }
51 
52 private:
53     // Data members
54     T const*        m_arr;
55     std::size_t     m_size;
56 };
57 
58 //____________________________________________________________________________//
59 
60 //! An array dataset is a dataset
61 template<typename T>
62 struct is_dataset<array<T>> : mpl::true_ {};
63 
64 } // namespace monomorphic
65 
66 //____________________________________________________________________________//
67 
68 //! @overload boost::unit_test::data::make()
69 template<typename T, std::size_t size>
70 inline monomorphic::array<typename boost::remove_const<T>::type>
make(T (& a)[size])71 make( T (&a)[size] )
72 {
73     return monomorphic::array<typename boost::remove_const<T>::type>( a, size );
74 }
75 
76 } // namespace data
77 } // namespace unit_test
78 } // namespace boost
79 
80 #include <boost/test/detail/enable_warnings.hpp>
81 
82 #endif // BOOST_TEST_DATA_MONOMORPHIC_ARRAY_HPP_121411GER
83 
84