Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** requires gcc5.0+ and C++14
- * g++ -std=c++14 -o test test.cpp
- */
- #include <iostream>
- /**
- * Struct with compiler-constant parameters
- */
- struct FFT_Inplace {
- static constexpr bool IsInplace = true;
- //..
- };
- /**
- * ... same, but different values ...
- */
- struct FFT_Outplace {
- static constexpr bool IsInplace = false;
- };
- /**
- * Our implementation for an FFT Plan+Execution.
- */
- template<typename TFFT>
- struct PlanImpl {
- static constexpr bool IsInplace = TFFT::IsInplace;
- void operator()() {
- std::cout << "IsInplace = " << IsInplace << std::endl;
- }
- };
- /**
- * Compiler-constant factory
- * TFFT is struct with compiler-constant parameters
- */
- template<
- typename TFFT,
- template<typename> typename TPlan
- >
- constexpr
- auto makePlan() {
- return TPlan<TFFT>();
- }
- /**
- * Let's play
- */
- int main(void)
- {
- auto inplace = makePlan<FFT_Inplace,PlanImpl>();
- inplace();
- auto outplace = makePlan<FFT_Outplace,PlanImpl>();
- outplace();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement