Skip to content

Commit

Permalink
boost::variant -> mpark::variant
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Feb 16, 2018
1 parent 239e6f5 commit d1ef948
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions include/auxiliary/Variadic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@
*/
#pragma once

// boost::variant uses boost::mpl::list to store template types
// the default length of the list is limited to 20 items,
// there are more dtypes handled in openPMD-api
// BOOST_MPL_LIMIT_LIST_SIZE has to be a multiple of 10
#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#define BOOST_MPL_LIMIT_LIST_SIZE 30

#include <boost/variant.hpp>
#include <mpark/variant.hpp>

#include <type_traits>

Expand All @@ -43,7 +36,7 @@ class Variadic
static_assert(std::is_enum< T_DTYPES >::value, "Datatypes to Variadic must be supplied as enum.");

public:
using resource = boost::variant< T ... >;
using resource = mpark::variant< T ... >;
/** Construct a lightweight wrapper around a generic object that indicates
* the concrete datatype of the specific object stored.
*
Expand All @@ -52,20 +45,20 @@ class Variadic
* @param r Generic object to be stored.
*/
Variadic(resource r)
: dtype{static_cast<T_DTYPES>(r.which())},
: dtype{static_cast<T_DTYPES>(r.index())},
m_data{r}
{ }

/** Retrieve a stored specific object of known datatype with ensured type-safety.
*
* @throw boost::bad_get if stored object is not of type U.
* @throw mpark::bad_variant_access if stored object is not of type U.
* @tparam U Type of the object to be retrieved.
* @return Copy of the retrieved object of type U.
*/
template< typename U >
U get() const
{
return boost::get< U >(m_data);
return mpark::get< U >(m_data);
}

/** Retrieve the stored generic object.
Expand Down

0 comments on commit d1ef948

Please sign in to comment.