Skip to content

Commit

Permalink
Make sure the function vtables are initialized before use
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Oct 13, 2017
1 parent d711115 commit 9a01810
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hpx/util/detail/basic_function.hpp
Expand Up @@ -60,7 +60,7 @@ namespace hpx { namespace util { namespace detail
{
// make sure the empty table instance is initialized in time, even
// during early startup
static VTable const* get_empty_table()
static VTable const* get_empty_table() noexcept
{
static VTable const empty_table =
detail::construct_vtable<detail::empty_function<R(Ts...)> >();
Expand Down
11 changes: 6 additions & 5 deletions hpx/util/detail/vtable/vtable.hpp
Expand Up @@ -25,20 +25,21 @@ namespace hpx { namespace util { namespace detail
template <typename VTable, typename T>
struct vtables
{
static VTable const instance;
static VTable const* get_vtable_instance() noexcept
{
static VTable const instance = construct_vtable<T>();
return &instance;
}
};

template <typename VTable, typename T>
VTable const vtables<VTable, T>::instance = construct_vtable<T>();

template <typename VTable, typename T>
HPX_CONSTEXPR inline VTable const* get_vtable() noexcept
{
static_assert(
std::is_same<T, typename std::decay<T>::type>::value,
"T shall have no cv-ref-qualifiers");

return &vtables<VTable, T>::instance;
return vtables<VTable, T>::get_vtable_instance();
}

///////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 9a01810

Please sign in to comment.