My Project
typeid.hpp
1 // Copyright Daniel Wallin 2008. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 
5 #ifndef LUABIND_TYPEID_081227_HPP
6 # define LUABIND_TYPEID_081227_HPP
7 
8 # include <boost/operators.hpp>
9 # include <typeinfo>
10 # include <luabind/detail/primitives.hpp>
11 
12 namespace luabind {
13 
14 # ifdef BOOST_MSVC
15 # pragma warning(push)
16 // std::type_info::before() returns int, rather than bool.
17 // At least on MSVC7.1, this is true for the comparison
18 // operators as well.
19 # pragma warning(disable:4800)
20 # endif
21 
22 class type_id
23  : public boost::less_than_comparable<type_id>
24 {
25 public:
26  type_id()
27  : id(&typeid(detail::null_type))
28  {}
29 
30  type_id(std::type_info const& id)
31  : id(&id)
32  {}
33 
34  bool operator!=(type_id const& other) const
35  {
36  return *id != *other.id;
37  }
38 
39  bool operator==(type_id const& other) const
40  {
41  return *id == *other.id;
42  }
43 
44  bool operator<(type_id const& other) const
45  {
46  return id->before(*other.id);
47  }
48 
49  char const* name() const
50  {
51  return id->name();
52  }
53 
54 private:
55  std::type_info const* id;
56 };
57 
58 # ifdef BOOST_MSVC
59 # pragma warning(pop)
60 # endif
61 
62 } // namespace luabind
63 
64 #endif // LUABIND_TYPEID_081227_HPP
65 
Definition: typeid.hpp:22
Definition: other.hpp:41
Definition: PEtypes.h:507
Definition: primitives.hpp:44