Skip to content

Commit

Permalink
Use inline variables for basic factories
Browse files Browse the repository at this point in the history
  • Loading branch information
jimporter committed Aug 14, 2024
1 parent dc5f2e7 commit 7fde185
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions include/mettle/suite/factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ namespace mettle {
namespace detail {

struct auto_factory_t {
constexpr auto_factory_t() {}

template<typename T>
T make() const {
return {};
}
};

struct type_only_factory_t {
constexpr type_only_factory_t() {}

template<typename T>
void make() const {}
};
Expand All @@ -38,9 +34,7 @@ namespace mettle {

template<typename T>
T make() const {
using Indices = std::make_index_sequence<
std::tuple_size<tuple_type>::value
>;
using Indices = std::make_index_sequence<std::tuple_size_v<tuple_type>>;
return make_impl<T>(Indices());
}
private:
Expand All @@ -54,8 +48,8 @@ namespace mettle {

}

constexpr detail::auto_factory_t auto_factory;
constexpr detail::type_only_factory_t type_only;
inline detail::auto_factory_t auto_factory;
inline detail::type_only_factory_t type_only;

template<typename ...Args>
auto bind_factory(Args &&...args) {
Expand Down

0 comments on commit 7fde185

Please sign in to comment.