-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🆕 Add
mp_quote_expr
to quote with lambda expressions
Problem: - There is no easy way to quote metafunction directly with lambda expressions. Solution: - Add mp_quote_expr. Note: - mp_quote_expr requires C++20.
- Loading branch information
1 parent
20aa0f9
commit 98605ce
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
// Copyright 2021 Kris Jusiak. | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// | ||
// See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt | ||
|
||
#include <boost/mp11/utility.hpp> | ||
#include <boost/mp11/algorithm.hpp> | ||
#include <boost/mp11/list.hpp> | ||
#include <boost/core/lightweight_test_trait.hpp> | ||
|
||
int main() | ||
{ | ||
#if defined(BOOST_MP11_HAS_NONTYPE_TEMPLATE) | ||
using boost::mp11::mp_list; | ||
using boost::mp11::mp_transform_q; | ||
using boost::mp11::mp_quote_expr; | ||
|
||
constexpr auto expr = [](auto t) { return t; }; | ||
|
||
{ | ||
BOOST_TEST_TRAIT_TRUE((std::is_same< | ||
mp_list<>, | ||
mp_transform_q< | ||
mp_quote_expr<expr>, | ||
mp_list<> | ||
> | ||
>)); | ||
} | ||
|
||
{ | ||
BOOST_TEST_TRAIT_TRUE((std::is_same< | ||
mp_list<int>, | ||
mp_transform_q< | ||
mp_quote_expr<expr>, | ||
mp_list<int> | ||
> | ||
>)); | ||
} | ||
|
||
struct a{}; | ||
struct b{}; | ||
|
||
{ | ||
BOOST_TEST_TRAIT_TRUE((std::is_same< | ||
mp_list<a, b>, | ||
mp_transform_q< | ||
mp_quote_expr<expr>, | ||
mp_list<a, b> | ||
> | ||
>)); | ||
} | ||
|
||
{ | ||
constexpr auto to_ptr = [](auto& t) { return &t; }; | ||
|
||
BOOST_TEST_TRAIT_TRUE((std::is_same< | ||
mp_list<a*, b*>, | ||
mp_transform_q< | ||
mp_quote_expr<to_ptr>, | ||
mp_list<a, b> | ||
> | ||
>)); | ||
} | ||
|
||
#endif | ||
return boost::report_errors(); | ||
} |