main
Brett 2025-04-26 00:40:39 -04:00
parent 5aacd7df9d
commit 5981a244c2
4 changed files with 15 additions and 21 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake)
set(BLT_VERSION 5.4.12)
set(BLT_VERSION 5.4.13)
set(BLT_TARGET BLT)

View File

@ -147,15 +147,6 @@ namespace blt
std::forward<Types>(args)...)
{}
// template <typename T, std::enable_if_t<!std::is_same_v<std::decay_t<T>, variant_t>, bool> = true>
// explicit constexpr variant_t(T&& t): m_variant(std::forward<T>(t))
// {}
// template<typename T>
// constexpr variant_t(std::initializer_list<T> il): m_variant(*il.begin())
// {
// }
template <typename T, typename... C_Args>
explicit constexpr variant_t(std::in_place_type_t<T>, C_Args&&... args): m_variant(std::in_place_type<T>, std::forward<C_Args>(args)...)
{}
@ -208,8 +199,15 @@ namespace blt
return m_variant.valueless_by_exception();
}
template <typename T, std::enable_if_t<std::conjunction_v<std::is_invocable<decltype(&T::operator()), T, Types>...> || std::conjunction_v<
std::is_invocable<decltype(&T::operator()), Types>...>, bool> = true>
constexpr auto visit(T&& visitor) -> decltype(auto)
{
return std::visit(std::forward<T>(visitor), m_variant);
}
template <typename... Visitee>
static constexpr auto make_visitor(Visitee&& visitees)
static constexpr auto make_visitor(Visitee&&... visitees)
{
// TODO: this is probably not the best way to handle these cases...
using meta_t = detail::visit_return_type<std::tuple<Visitee...>, std::tuple<Types...>>;
@ -225,8 +223,7 @@ namespace blt
return typename meta_t::return_type{};
} else
{
return typename meta_t::return_type(
std::forward<Visitee>(visitees)(std::forward<decltype(value)>(value)));
return typename meta_t::return_type(std::forward<Visitee>(visitees)(std::forward<decltype(value)>(value)));
}
}...
};
@ -247,8 +244,7 @@ namespace blt
} else
{
return typename meta_t::return_type(
typename meta_t::base_type(
std::forward<Visitee>(visitees)(std::forward<decltype(value)>(value))));
typename meta_t::base_type(std::forward<Visitee>(visitees)(std::forward<decltype(value)>(value))));
}
}...
};
@ -256,9 +252,7 @@ namespace blt
{
return lambda_visitor{
[&](std::tuple_element_t<0, typename meta::function_like<Visitee>::args_tuple> value) {
return typename meta_t::return_type{
std::forward<Visitee>(visitees)(std::forward<decltype(value)>(value))
};
return typename meta_t::return_type{std::forward<Visitee>(visitees)(std::forward<decltype(value)>(value))};
}...
};
}

@ -1 +1 @@
Subproject commit 7ef2e733416953b222851f9a360d7fc72d068ee5
Subproject commit 93201da2ba5a6aba0a6e57ada64973555629b3e3

View File

@ -15,9 +15,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <blt/std/variant.h>
#include <blt/logging/logging.h>
#include <blt/std/assert.h>
#include <blt/std/variant.h>
struct base_type
{