-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
badair
committed
May 25, 2016
1 parent
ac90473
commit 5de2361
Showing
5 changed files
with
151 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright Barrett Adair 2016 | ||
Distributed under the Boost Software License, Version 1.0. | ||
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | ||
*/ | ||
|
||
#include <cassert> | ||
#include <type_traits> | ||
#include <functional> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <memory> | ||
#include <iostream> | ||
#include <cstdint> | ||
#include "bind_parser.hpp" | ||
|
||
struct Vampire {}; | ||
struct Robot {}; | ||
struct Animal {}; | ||
struct Dog : Animal {}; | ||
struct Poodle : Dog {}; | ||
struct ScaryMonster : Poodle, Robot, Vampire {}; | ||
|
||
int main() { | ||
|
||
{ | ||
using test = bind_parser::detail::best_match< | ||
Vampire, Robot, Poodle, Animal, Dog, ScaryMonster>; | ||
|
||
using expect = ScaryMonster; | ||
|
||
static_assert(std::is_same<test, expect>::value, ""); | ||
} | ||
} |
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,68 @@ | ||
/* | ||
Copyright Barrett Adair 2016 | ||
Distributed under the Boost Software License, Version 1.0. | ||
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | ||
*/ | ||
|
||
#include <type_traits> | ||
#include <functional> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <memory> | ||
#include <iostream> | ||
#include <cstdint> | ||
#include "bind_parser.hpp" | ||
|
||
using namespace std::placeholders; | ||
|
||
struct A {}; | ||
struct B {}; | ||
struct C {}; | ||
struct D {}; | ||
struct E {}; | ||
struct F {}; | ||
struct G {}; | ||
|
||
// functions `ordered_letters`, `BEEF_returns_D`, `BEEF_returns_G`, | ||
// and `BEEF_returns_B` are used to set up a complex bind expression | ||
// with bind | ||
|
||
auto ordered_letters(A, B, C, D, E, F, G) { | ||
return 0; | ||
} | ||
|
||
auto BEEF_returns_D(B, E, E, F) { | ||
return D{}; | ||
} | ||
|
||
auto BEEF_returns_G(B, E, E, F) { | ||
return G{}; | ||
} | ||
|
||
auto BEEF_returns_B(B, E, E, F) { | ||
return B{}; | ||
} | ||
|
||
#define INNER_3 bind_parser::bind(&BEEF_returns_B, B{}, _10, E{}, F{}) | ||
#define INNER_2 bind_parser::bind(&BEEF_returns_G, INNER_3, _9, E{}, _8) | ||
#define INNER_1 bind_parser::bind(&BEEF_returns_D, _2, E{}, _4, _7) | ||
|
||
int main() { | ||
|
||
auto root = bind_parser::bind(&ordered_letters, _1, _2, _3, INNER_1, _5, _6, INNER_2); | ||
|
||
using test = decltype(root)::flattened_bind_expressions; | ||
|
||
using expect = std::tuple< | ||
decltype(root), | ||
decltype(INNER_1), | ||
decltype(INNER_2), | ||
decltype(INNER_3) | ||
>; | ||
|
||
static_assert(std::is_same<test, expect>::value, ""); | ||
|
||
return 0; | ||
} |
This file was deleted.
Oops, something went wrong.
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