Skip to content

Commit

Permalink
Merge pull request #1255 from joshuak94/byebyemeta
Browse files Browse the repository at this point in the history
[MISC] Replace usage of the meta library.
  • Loading branch information
smehringer authored Nov 12, 2019
2 parents ca421a4 + 814f0b9 commit cf417c8
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 229 deletions.
35 changes: 17 additions & 18 deletions include/seqan3/argument_parser/detail/format_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
#include <sstream>
#include <string>

#include <meta/meta.hpp>

#include <seqan3/argument_parser/auxiliary.hpp>
#include <seqan3/argument_parser/exceptions.hpp>
#include <seqan3/argument_parser/validators.hpp>
#include <seqan3/core/detail/reflection.hpp>
#include <seqan3/core/type_list/traits.hpp>
#include <seqan3/std/filesystem>

namespace seqan3::detail
Expand All @@ -43,20 +42,20 @@ class format_base
static std::string get_type_name_as_string(value_type const & /**/)
{
using type = std::decay_t<value_type>;
using types = meta::list<int8_t,
uint8_t,
int16_t,
uint16_t,
int32_t,
uint32_t,
int64_t,
uint64_t,
double,
float,
bool,
char,
std::string,
std::filesystem::path>;
using types = type_list<int8_t,
uint8_t,
int16_t,
uint16_t,
int32_t,
uint32_t,
int64_t,
uint64_t,
double,
float,
bool,
char,
std::string,
std::filesystem::path>;
std::vector<std::string> names{"signed 8 bit integer",
"unsigned 8 bit integer",
"signed 16 bit integer",
Expand All @@ -72,8 +71,8 @@ class format_base
"std::string",
"std::filesystem::path"};

if constexpr (meta::in<types, type>::value)
return names[meta::find_index<types, type>::value];
if constexpr (list_traits::contains<type, types>)
return names[list_traits::find<type, types>];
else
return detail::get_display_name_v<value_type>.str();
}
Expand Down
27 changes: 11 additions & 16 deletions include/seqan3/core/algorithm/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <seqan3/core/algorithm/concept.hpp>
#include <seqan3/core/algorithm/configuration_utility.hpp>
#include <seqan3/core/algorithm/pipeable_config_element.hpp>
#include <seqan3/core/type_traits/basic.hpp>
#include <seqan3/core/type_traits/template_inspection.hpp>
#include <seqan3/core/type_list/traits.hpp>
#include <seqan3/core/tuple_utility.hpp>
#include <seqan3/core/type_list/type_list.hpp>
#include <seqan3/std/concepts>
Expand Down Expand Up @@ -276,13 +275,13 @@ class configuration : public std::tuple<configs_t...>
template <typename query_t>
static constexpr bool exists() noexcept
{
return !meta::empty<meta::find<type_list<configs_t...>, query_t>>::value;
return pack_traits::contains<query_t, configs_t...>;
}
//!\brief Checks if the given type exists in the tuple.
template <template <typename ...> typename query_t>
static constexpr bool exists() noexcept
{
return !meta::empty<meta::find_if<type_list<configs_t...>, detail::is_same_configuration_f<query_t>>>::value;
return (pack_traits::find_if<detail::is_same_configuration_f<query_t>::template invoke, configs_t...> > -1);
}
//!\}

Expand Down Expand Up @@ -566,43 +565,39 @@ configuration(pipeable_config_element<derived_t, value_t> const &) -> configurat
template <template <typename ...> class query_t, typename ...configs_t>
constexpr auto & get(configuration<configs_t...> & config) noexcept
{
using _tail = meta::find_if<type_list<configs_t...>, detail::is_same_configuration_f<query_t>>;
static_assert(!meta::empty<_tail>::value, "Access error: The requested type is not contained.");
constexpr auto pos = pack_traits::find_if<detail::is_same_configuration_f<query_t>::template invoke, configs_t...>;
static_assert(pos > -1, "Access error: The requested type is not contained.");

constexpr size_t pos = sizeof...(configs_t) - meta::size<_tail>::value;
return get<pos>(config);
}

//!\overload
template <template <typename ...> class query_t, typename ...configs_t>
constexpr auto const & get(configuration<configs_t...> const & config) noexcept
{
using _tail = meta::find_if<type_list<configs_t...>, detail::is_same_configuration_f<query_t>>;
static_assert(!meta::empty<_tail>::value, "Access error: The requested type is not contained.");
constexpr auto pos = pack_traits::find_if<detail::is_same_configuration_f<query_t>::template invoke, configs_t...>;
static_assert(pos > -1, "Access error: The requested type is not contained.");

constexpr size_t pos = sizeof...(configs_t) - meta::size<_tail>::value;
return get<pos>(config);
}

//!\overload
template <template <typename ...> class query_t, typename ...configs_t>
constexpr auto && get(configuration<configs_t...> && config) noexcept
{
using _tail = meta::find_if<type_list<configs_t...>, detail::is_same_configuration_f<query_t>>;
static_assert(!meta::empty<_tail>::value, "Access error: The requested type is not contained.");
constexpr auto pos = pack_traits::find_if<detail::is_same_configuration_f<query_t>::template invoke, configs_t...>;
static_assert(pos > -1, "Access error: The requested type is not contained.");

constexpr size_t pos = sizeof...(configs_t) - meta::size<_tail>::value;
return get<pos>(std::move(config));
}

//!\overload
template <template <typename ...> class query_t, typename ...configs_t>
constexpr auto const && get(configuration<configs_t...> const && config) noexcept
{
using _tail = meta::find_if<type_list<configs_t...>, detail::is_same_configuration_f<query_t>>;
static_assert(!meta::empty<_tail>::value, "Access error: The requested type is not contained.");
constexpr auto pos = pack_traits::find_if<detail::is_same_configuration_f<query_t>::template invoke, configs_t...>;
static_assert(pos > -1, "Access error: The requested type is not contained.");

constexpr size_t pos = sizeof...(configs_t) - meta::size<_tail>::value;
// TODO: change after GCC-7 bug with const && version of get in std::tuple is fixed.
// return get<pos>(std::move(config));
return std::move(get<pos>(config));
Expand Down
45 changes: 14 additions & 31 deletions include/seqan3/core/pod_tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
#include <tuple>
#include <type_traits>

#include <meta/meta.hpp>

#include <seqan3/core/platform.hpp>
#include <seqan3/core/type_list/traits.hpp>

namespace seqan3
{
Expand Down Expand Up @@ -245,51 +244,43 @@ constexpr auto const && get(seqan3::pod_tuple<types...> const && t) noexcept
template <typename type, typename ...arg_types>
constexpr auto & get(seqan3::pod_tuple<arg_types...> & t) noexcept
//!\cond
requires meta::in<meta::list<arg_types...>, type>::value &&
(meta::find_index<meta::list<arg_types...>, type>::value ==
meta::reverse_find_index<meta::list<arg_types...>, type>::value)
requires (seqan3::pack_traits::count<type, arg_types...> == 1)
//!\endcond
{
return seqan3::get<meta::find_index<meta::list<arg_types...>, type>::value>(t);
return seqan3::get<seqan3::pack_traits::find<type, arg_types...>>(t);
}

//!\brief The same as [std::get](https://en.cppreference.com/w/cpp/utility/tuple/get) on an std::tuple.
//!\relates seqan3::pod_tuple
template <typename type, typename ...arg_types>
constexpr auto const & get(seqan3::pod_tuple<arg_types...> const & t) noexcept
//!\cond
requires meta::in<meta::list<arg_types...>, type>::value &&
(meta::find_index<meta::list<arg_types...>, type>::value ==
meta::reverse_find_index<meta::list<arg_types...>, type>::value)
requires (seqan3::pack_traits::count<type, arg_types...> == 1)
//!\endcond
{
return seqan3::get<meta::find_index<meta::list<arg_types...>, type>::value>(t);
return seqan3::get<seqan3::pack_traits::find<type, arg_types...>>(t);
}

//!\brief The same as [std::get](https://en.cppreference.com/w/cpp/utility/tuple/get) on an std::tuple.
//!\relates seqan3::pod_tuple
template <typename type, typename ...arg_types>
constexpr auto && get(seqan3::pod_tuple<arg_types...> && t) noexcept
//!\cond
requires meta::in<meta::list<arg_types...>, type>::value &&
(meta::find_index<meta::list<arg_types...>, type>::value ==
meta::reverse_find_index<meta::list<arg_types...>, type>::value)
requires (seqan3::pack_traits::count<type, arg_types...> == 1)
//!\endcond
{
return seqan3::get<meta::find_index<meta::list<arg_types...>, type>::value>(std::move(t));
return seqan3::get<seqan3::pack_traits::find<type, arg_types...>>(std::move(t));
}

//!\brief The same as [std::get](https://en.cppreference.com/w/cpp/utility/tuple/get) on an std::tuple.
//!\relates seqan3::pod_tuple
template <typename type, typename ...arg_types>
constexpr auto const && get(seqan3::pod_tuple<arg_types...> const && t) noexcept
//!\cond
requires meta::in<meta::list<arg_types...>, type>::value &&
(meta::find_index<meta::list<arg_types...>, type>::value ==
meta::reverse_find_index<meta::list<arg_types...>, type>::value)
requires (seqan3::pack_traits::count<type, arg_types...> == 1)
//!\endcond
{
return seqan3::get<meta::find_index<meta::list<arg_types...>, type>::value>(std::move(t));
return seqan3::get<seqan3::pack_traits::find<type, arg_types...>>(std::move(t));
}
//!\}

Expand Down Expand Up @@ -329,36 +320,28 @@ constexpr auto const && get(seqan3::pod_tuple<types...> const && t) noexcept

template <typename type, typename ...types>
constexpr auto & get(seqan3::pod_tuple<types...> & t) noexcept
requires meta::in<meta::list<types...>, type>::value &&
(meta::find_index<meta::list<types...>, type>::value ==
meta::reverse_find_index<meta::list<types...>, type>::value)
requires (seqan3::pack_traits::count<type, types...> == 1)
{
return seqan3::get<type>(t);
}

template <typename type, typename ...types>
constexpr auto const & get(seqan3::pod_tuple<types...> const & t) noexcept
requires meta::in<meta::list<types...>, type>::value &&
(meta::find_index<meta::list<types...>, type>::value ==
meta::reverse_find_index<meta::list<types...>, type>::value)
requires (seqan3::pack_traits::count<type, types...> == 1)
{
return seqan3::get<type>(t);
}

template <typename type, typename ...types>
constexpr auto && get(seqan3::pod_tuple<types...> && t) noexcept
requires meta::in<meta::list<types...>, type>::value &&
(meta::find_index<meta::list<types...>, type>::value ==
meta::reverse_find_index<meta::list<types...>, type>::value)
requires (seqan3::pack_traits::count<type, types...> == 1)
{
return seqan3::get<type>(std::move(t));
}

template <typename type, typename ...types>
constexpr auto const && get(seqan3::pod_tuple<types...> const && t) noexcept
requires meta::in<meta::list<types...>, type>::value &&
(meta::find_index<meta::list<types...>, type>::value ==
meta::reverse_find_index<meta::list<types...>, type>::value)
requires (seqan3::pack_traits::count<type, types...> == 1)
{
return seqan3::get<type>(std::move(t));
}
Expand All @@ -374,7 +357,7 @@ template <std::size_t i, template <typename ...> typename t, typename ...types>
std::is_base_of_v<seqan3::pod_tuple<types...>, t<types...>>
struct tuple_element<i, t<types...>>
{
using type = meta::at_c<meta::list<types...>, i>;
using type = seqan3::pack_traits::at<i, types...>;
};

/*!\brief Provides access to the number of elements in a tuple as a compile-time constant expression.
Expand Down
8 changes: 2 additions & 6 deletions include/seqan3/core/tuple_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@

#pragma once

#include <meta/meta.hpp>

#include <utility>

#include <seqan3/core/concept/tuple.hpp>
#include <seqan3/core/pod_tuple.hpp>
#include <seqan3/core/type_list/type_list.hpp>
#include <seqan3/core/type_traits/basic.hpp>
#include <seqan3/core/type_traits/template_inspection.hpp>
#include <seqan3/core/type_list/traits.hpp>

namespace seqan3::detail
{
Expand Down Expand Up @@ -152,7 +148,7 @@ constexpr auto tuple_split(tuple_t<ts...> && t)
template <typename pivot_t, tuple_like tuple_t>
constexpr auto tuple_split(tuple_t && t)
{
constexpr size_t pivot_c = meta::find_index<detail::tuple_type_list_t<remove_cvref_t<tuple_t>>, pivot_t>::value;
constexpr size_t pivot_c = list_traits::find<pivot_t, detail::tuple_type_list_t<remove_cvref_t<tuple_t>>>;

static_assert(pivot_c <= std::tuple_size_v<remove_cvref_t<tuple_t>>);

Expand Down
3 changes: 2 additions & 1 deletion include/seqan3/core/type_list/traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ inline constexpr ptrdiff_t find = -1;
* \include test/snippet/core/type_list/list_traits_find.cpp
*/
template <typename query_t, typename ...pack_t>
inline constexpr ptrdiff_t find<query_t,type_list<pack_t...>> = seqan3::pack_traits::detail::find<query_t, pack_t...>();
inline constexpr ptrdiff_t find<query_t, type_list<pack_t...>> =
seqan3::pack_traits::detail::find<query_t, pack_t...>();

//!\cond
template <template <typename> typename pred_t, seqan3::detail::type_list_specialisation list_t>
Expand Down
3 changes: 2 additions & 1 deletion include/seqan3/core/type_traits/transformation_trait_or.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <meta/meta.hpp>

#include <seqan3/core/platform.hpp>
#include <seqan3/core/type_traits/concept.hpp>
#include <seqan3/std/type_traits>

namespace seqan3::detail
Expand All @@ -42,7 +43,7 @@ namespace seqan3::detail
* seqan3::detail::transformation_trait_or_t as a shorthand for *seqan3::detail::transformation_trait_or::type*
*/
template <typename type_t, typename default_t>
using transformation_trait_or = std::conditional_t<meta::is_trait<type_t>::value, // check if type_t::type exists
using transformation_trait_or = std::conditional_t<transformation_trait<type_t>, // check if type_t::type exists
type_t, // if yes, return type_t
std::type_identity<default_t>>; // else return default_t as trait

Expand Down
4 changes: 2 additions & 2 deletions include/seqan3/io/alignment_file/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/alphabet/quality/qualified.hpp>
#include <seqan3/core/concept/tuple.hpp>
#include <seqan3/core/type_traits/basic.hpp>
#include <seqan3/core/type_list/traits.hpp>
#include <seqan3/core/type_traits/transformation_trait_or.hpp>
#include <seqan3/io/alignment_file/input_format_concept.hpp>
#include <seqan3/io/alignment_file/format_bam.hpp>
Expand Down Expand Up @@ -856,7 +856,7 @@ class alignment_file_input
template <typename format_type>
void init(format_type const &)
{
static_assert(meta::in<valid_formats, format_type>::value,
static_assert(list_traits::contains<format_type, valid_formats>,
"You selected a format that is not in the valid_formats of this file.");

format = detail::alignment_file_input_format_REMOVEME<format_type>{};
Expand Down
7 changes: 3 additions & 4 deletions include/seqan3/io/alignment_file/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
#include <vector>

#include <seqan3/core/concept/tuple.hpp>
#include <seqan3/core/type_traits/basic.hpp>
#include <seqan3/core/type_traits/template_inspection.hpp>
#include <seqan3/core/type_list/traits.hpp>
#include <seqan3/io/alignment_file/format_bam.hpp>
#include <seqan3/io/alignment_file/format_sam.hpp>
#include <seqan3/io/alignment_file/header.hpp>
Expand Down Expand Up @@ -340,7 +339,7 @@ class alignment_file_output
secondary_stream{&stream, stream_deleter_noop},
format{detail::alignment_file_output_format_REMOVEME<file_format>{}}
{
static_assert(meta::in<valid_formats, file_format>::value,
static_assert(list_traits::contains<file_format, valid_formats>,
"You selected a format that is not in the valid_formats of this file.");
}

Expand All @@ -353,7 +352,7 @@ class alignment_file_output
secondary_stream{&*primary_stream, stream_deleter_noop},
format{detail::alignment_file_output_format_REMOVEME<file_format>{}}
{
static_assert(meta::in<valid_formats, file_format>::value,
static_assert(list_traits::contains<file_format, valid_formats>,
"You selected a format that is not in the valid_formats of this file.");
}

Expand Down
10 changes: 5 additions & 5 deletions include/seqan3/io/detail/misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <seqan3/core/detail/pack_algorithm.hpp>
#include <seqan3/core/type_traits/template_inspection.hpp>
#include <seqan3/core/type_list/type_list.hpp>
#include <seqan3/core/type_list/traits.hpp>
#include <seqan3/io/exception.hpp>
#include <seqan3/io/sequence_file/input_format_concept.hpp>
#include <seqan3/std/algorithm>
Expand All @@ -33,8 +33,8 @@ struct variant_from_tags;

//!\brief Transfers a list of format tags (`...ts`) onto a std::variant by specialising output_t with each.
//!\ingroup io
template <template <typename ...> typename output_t, typename ...ts>
struct variant_from_tags<meta::list<ts...>, output_t>
template <template <typename...> typename output_t, typename ...ts>
struct variant_from_tags<type_list<ts...>, output_t>
{
//!\brief The type of std::variant.
using type = std::variant<output_t<ts>...>;
Expand Down Expand Up @@ -76,9 +76,9 @@ void set_format(format_variant_type & format,
if (extension.size() > 1)
{
extension = extension.substr(1); // drop leading "."
meta::for_each(valid_formats{}, [&] (auto && fmt)
detail::for_each<valid_formats>([&] (auto fmt)
{
using fmt_type = remove_cvref_t<decltype(fmt)>;
using fmt_type = remove_cvref_t<typename decltype(fmt)::type>;
using fmt_tag = typename fmt_type::format_tag;

for (auto const & ext : fmt_tag::file_extensions)
Expand Down
Loading

0 comments on commit cf417c8

Please sign in to comment.