-
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.
Refactored into separate source files
- Loading branch information
1 parent
ce6f711
commit 2951609
Showing
10 changed files
with
1,101 additions
and
1,024 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,10 @@ | ||
project(Examples) | ||
|
||
add_executable(test-depend depend.cc) | ||
target_link_libraries(test-depend LINK_PUBLIC dependent-cxx) | ||
|
||
add_executable(test-log2 log2.cc) | ||
target_link_libraries(test-log2 LINK_PUBLIC dependent-cxx) | ||
|
||
add_executable(test-array-concat array-concat.cc) | ||
target_link_libraries(test-array-concat LINK_PUBLIC dependent-cxx) |
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,28 @@ | ||
#include <dependent-cxx/algebra.hpp> | ||
#include <dependent-cxx/array.hpp> | ||
#include <dependent-cxx/core-io.hpp> | ||
|
||
using namespace dependent_cxx; | ||
|
||
// WIP demo of concatenating a dynamic length array with a static length array | ||
int main(int argc, const char* argv[]) { | ||
RootFrame(); | ||
constexpr auto v32 = FreshType(32); | ||
if constexpr (constexpr auto proofNonneg = algebra::less_than_or_equal_to<Zero,TYPEOF(v32)>::apply(Zero{}, v32, Context{}); | ||
std::nullopt == proofNonneg) { | ||
std::cerr << "Can't make negative-length array" << std::endl; | ||
} else { | ||
constexpr algebra::less_than_or_equal_to<Zero, TYPEOF(v32)> lte_ev = *proofNonneg; | ||
collections::Array<FreshTag(), float, TYPEOF(v32)> a32(v32, lte_ev); | ||
|
||
constexpr Constant<64> SixtyFour; | ||
constexpr algebra::less_than_or_equal_to<Zero, TYPEOF(SixtyFour)> sixty_four_nn{Zero{}, SixtyFour}; | ||
collections::Array<FreshTag(), float, TYPEOF(SixtyFour)> a64(SixtyFour, sixty_four_nn); | ||
|
||
//auto a96{collections::concatenate<FreshTag()>(a64, a32)}; | ||
// TODO: finish implementing concatenate | ||
|
||
} | ||
|
||
return 0; | ||
} |
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,28 @@ | ||
// WIP: proof that a variant is one of a only a subset of possible values | ||
/* | ||
template<class OldVar, class NewVar> | ||
class SubsetVariant {}; | ||
template<class OldVarH, class ...OldVarTs, class ...NewVars> | ||
class SubsetVariant<std::variant<OldVarH, OldVarTs...>,std::variant<NewVars...>> { | ||
template<class Head, class ...Tail> | ||
inline static std::variant<OldVarH, OldVarTs...> applyHelper(std::variant<NewVars...> input) { | ||
if(std::holds_alternative<Head>(input)) { | ||
return std::get<Head>(input); | ||
} else { | ||
return applyHelper<Tail...>(input); | ||
} | ||
} | ||
template<class ...N, std::enable_if_t<sizeof...(N) == 0, bool> = true> | ||
inline static std::variant<OldVarH, OldVarTs...> applyHelper(std::variant<NewVars...> ) { | ||
static_assert(sizeof...(N) == 0); | ||
return std::variant<OldVarH, OldVarTs...>(([]() -> OldVarH { throw std::logic_error("These don't overlap"); })()); | ||
} | ||
public: | ||
constexpr static std::variant<OldVarH, OldVarTs...> apply(std::variant<NewVars...> input) { | ||
return applyHelper<OldVarH, OldVarTs...>(input); | ||
}; | ||
}; | ||
*/ |
Oops, something went wrong.