Skip to content

Commit

Permalink
C++17: Use std::variant
Browse files Browse the repository at this point in the history
Do not use the MPark.Variant library if users compile with C++17
  • Loading branch information
ax3l committed Feb 16, 2018
1 parent 193d533 commit 3dccfc4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions include/auxiliary/Variadic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
*/
#pragma once

#include <mpark/variant.hpp>
#if __cplusplus >= 201703L
# include <variant>
namespace variadicSrc = std;
#else
# include <mpark/variant.hpp>
namespace variadicSrc = mpark;
#endif

#include <type_traits>

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

public:
using resource = mpark::variant< T ... >;
using resource = variadicSrc::variant< T ... >;
/** Construct a lightweight wrapper around a generic object that indicates
* the concrete datatype of the specific object stored.
*
Expand All @@ -51,14 +57,14 @@ class Variadic

/** Retrieve a stored specific object of known datatype with ensured type-safety.
*
* @throw mpark::bad_variant_access if stored object is not of type U.
* @throw std::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 mpark::get< U >(m_data);
return variadicSrc::get< U >(m_data);
}

/** Retrieve the stored generic object.
Expand Down

0 comments on commit 3dccfc4

Please sign in to comment.