Skip to content

Commit

Permalink
Merge branch 'dev-4.2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
gracicot committed May 6, 2020
2 parents b77cc03 + 6b2a17e commit 8da8f0d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 35 deletions.
24 changes: 0 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,30 +143,6 @@ matrix:
- ENABLE_CXX14=true
- ENABLE_CXX17=true

- os: osx
osx_image: xcode9.2
env:
- ENABLE_CXX14=true
- ENABLE_CXX17=true

- os: osx
osx_image: xcode9.1
env:
- ENABLE_CXX14=true
- ENABLE_CXX17=true

- os: osx
osx_image: xcode9
env:
- ENABLE_CXX14=true
- ENABLE_CXX17=true

- os: osx
osx_image: xcode8.3
env:
- ENABLE_CXX14=true
- ENABLE_CXX17=true

install:
############################################################################
# All the dependencies are installed in ${TRAVIS_BUILD_DIR}/deps/
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 11)

set(KANGARU_VERSION_MAJOR "4")
set(KANGARU_VERSION_MINOR "2")
set(KANGARU_VERSION_PATCH "2")
set(KANGARU_VERSION_PATCH "4")

set(KANGARU_VERSION "${KANGARU_VERSION_MAJOR}.${KANGARU_VERSION_MINOR}.${KANGARU_VERSION_PATCH}")

Expand Down
14 changes: 11 additions & 3 deletions include/kangaru/detail/define.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,19 @@
#endif // KGR_KANGARU_MSVC_EXACT_DECLTYPE

#ifndef KGR_KANGARU_EMPTY_BASES
#if defined(_MSC_VER)
#ifdef _MSC_VER
#define KGR_KANGARU_EMPTY_BASES __declspec(empty_bases)
#else
#define KGR_KANGARU_EMPTY_BASES
#endif
#endif
#endif // _MSC_VER
#endif // KGR_KANGARU_EMPTY_BASES

#ifndef KGR_KANGARU_NONCONST_TYPEID
#ifdef _MSC_VER
#ifndef __clang__
#define KGR_KANGARU_NONCONST_TYPEID
#endif // !__clang__
#endif // _MSC_VER
#endif // KGR_KANGARU_NONCONST_TYPEID

#endif // KGR_KANGARU_INCLUDE_KANGARU_DETAIL_DEFINE
1 change: 1 addition & 0 deletions include/kangaru/detail/undef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#undef KGR_KANGARU_MSVC_NO_DEPENDENT_TEMPLATE_KEYWORD
#undef KGR_KANGARU_MSVC_EXACT_DECLTYPE
#undef KGR_KANGARU_EMPTY_BASES
#undef KGR_KANGARU_NONCONST_TYPEID

// These two header are meant to be included
// everytime they are needed since they cancel each other
Expand Down
25 changes: 18 additions & 7 deletions include/kangaru/type_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <cstdint>
#include <type_traits>

#include "detail/define.hpp"

namespace kgr {
namespace detail {

Expand All @@ -29,7 +31,7 @@ struct is_index_storage<index_storage<T>> : std::true_type {};
* get it's pointer. We reuse that space to store meta information.
*/
struct type_id_data {
enum struct kind_t : std::uint8_t { normal, override_storage, index_storage } kind;
enum struct kind_t : std::uint8_t { normal, override_storage, index_storage } const kind;

template<typename T>
static constexpr auto kind_for() noexcept -> type_id_data {
Expand All @@ -48,13 +50,14 @@ struct type_id_data {
*/
template<typename T>
struct type_id_ptr {
struct id_t {
type_id_data data;
};

// Having a static data member will ensure us that it has only one address for the whole program.
// Furthermore, the static data member having different types will ensure it won't get optimized.
static constexpr id_t id = id_t{type_id_data::kind_for<T>()};
// Furthermore, the static data member all the same type will ensure it won't get optimized.
#ifdef KGR_KANGARU_NONCONST_TYPEID
static type_id_data id;
#else
static constexpr type_id_data id = type_id_data::kind_for<T>();
#endif
};

/*
Expand All @@ -67,8 +70,14 @@ struct type_id_ptr {
*
* Using the pointer of a static data member is more stable.
*/

#ifdef KGR_KANGARU_NONCONST_TYPEID
template<typename T>
constexpr typename type_id_ptr<T>::id_t const type_id_ptr<T>::id;
type_id_data type_id_ptr<T>::id = type_id_data::kind_for<T>();
#else
template<typename T>
constexpr type_id_data const type_id_ptr<T>::id;
#endif

inline constexpr auto type_id_kind(void const* id) -> type_id_data::kind_t {
return static_cast<type_id_data const*>(id)->kind;
Expand All @@ -94,4 +103,6 @@ constexpr auto type_id() -> type_id_t {

} // namespace kgr

#include "detail/undef.hpp"

#endif // KGR_KANGARU_INCLUDE_KANGARU_TYPE_ID_HPP

0 comments on commit 8da8f0d

Please sign in to comment.