File: test_vector_of_number.cpp

package info (click to toggle)
luabind 0.9.1%2Bgit20150823%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,692 kB
  • sloc: cpp: 14,884; makefile: 204; sh: 41; python: 38; ansic: 11
file content (52 lines) | stat: -rw-r--r-- 1,749 bytes parent folder | download | duplicates (2)
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
43
44
45
46
47
48
49
50
51
52
// Copyright Christian Neumüller 2016. Use, modification and distribution is
// subject to 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)

// Test case by github.com/AndriyAstakhov

#include "test.hpp"
#include <luabind/luabind.hpp>
#include <vector>
#include <boost/static_assert.hpp>

#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/enable_if.hpp>

using namespace luabind;

void test_main(lua_State* L)
{
    BOOST_STATIC_ASSERT((boost::is_base_and_derived<
        number_converter<double const>,
        default_converter<double const> >::value));

    BOOST_STATIC_ASSERT((boost::is_base_and_derived<
        number_converter<double const&>,
        default_converter<double const&> >::value));

    BOOST_STATIC_ASSERT((!boost::is_base_and_derived<
        number_converter<double&>,
        default_converter<double&> >::value));

    module(L) [
        class_<std::vector<double> >("vector_double")
            .def(constructor<>())
            .def(
                "push_back",
                static_cast<void(std::vector<double>::*)(const double&)>(
                    &std::vector<double>::push_back))
    ];

    DOSTRING(L,
        "local vecDouble = vector_double()\n"
        "vecDouble:push_back(1.5)\n");
}