Skip to content

Commit

Permalink
is_consteval
Browse files Browse the repository at this point in the history
  • Loading branch information
deepgrace committed Apr 27, 2024
1 parent 83689a8 commit 80bae99
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,12 @@ int main(int argc, char* argv[])
a = std::string("[]<template auto ...>(){}();");
any_visit(show, a);

is_identical<is_consteval([]{})>();
is_identical<!is_consteval(show)>();

is_identical<is_consteval_v<decltype([]{})>>();
is_identical<!is_consteval_v<std::tuple<int>>>();

capture_invoke(pf)(1, 2, 3);
capture_invoke(pf, 3)(1, 2);

Expand Down
6 changes: 6 additions & 0 deletions example/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,12 @@ int main(int argc, char* argv[])
a = std::string("[]<template auto ...>(){}();");
any_visit(show, a);

is_identical<is_consteval([]{})>();
is_identical<!is_consteval(show)>();

is_identical<is_consteval_v<decltype([]{})>>();
is_identical<!is_consteval_v<std::tuple<int>>>();

capture_invoke(pf)(1, 2, 3);
capture_invoke(pf, 3)(1, 2);

Expand Down
9 changes: 9 additions & 0 deletions include/monster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5613,6 +5613,15 @@ namespace monster
template <typename... Args>
overload_sequence(Args&&...) -> overload_sequence<Args...>;

template <typename T>
consteval bool is_consteval(T&& t)
{
return requires { typename std::bool_constant<(t(), true)>; };
}

template <typename T>
inline constexpr auto is_consteval_v = is_consteval(T());

template <auto... N, typename F, typename... Args>
constexpr decltype(auto) call_operator(F&& f, Args&&... args)
{
Expand Down
2 changes: 1 addition & 1 deletion include/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* time a set of code changes is merged to the master branch.
*/

#define MONSTER_VERSION_NUMBER 311
#define MONSTER_VERSION_NUMBER 312
#define MONSTER_VERSION_STRING "Monster/" MONSTER_STRINGIZE(MONSTER_VERSION_NUMBER)

#endif

0 comments on commit 80bae99

Please sign in to comment.