chlorie / meta Goto Github PK
View Code? Open in Web Editor NEWExperiencing with C++17 template meta-programming
Experiencing with C++17 template meta-programming
Hello,
谢谢你提供的代码。它看起来在Visual Studio的框架下非常好用,并且能够得到有效的执行。
但是我在我的电脑上运行时,似乎出现了状况:
OS:Linux 4.19.0-8-amd64 #1
SMP Debian 4.19.98-1 (2020-01-26) x86_64 GNU/Linux
IDE:Clion 2019.3.5
g++:version 8.3.0 (Debian 8.3.0-6)
Cmake:3.13
Problems: 当我尝试进行生成程序时,遇到如下问题:
====================[ Build | Meta_Algotirhm | Debug ]========================== /usr/clion-2019.3.5/bin/cmake/linux/bin/cmake --build "/home/wz18207/CLionProjects/Meta Algotirhm/cmake-build-debug" --target Meta_Algotirhm -- -j 1 [ 50%] Building CXX object CMakeFiles/Meta_Algotirhm.dir/main.cpp.o In file included from /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:2, from /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:3: /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:5:54: error: ‘index_sequence’ in namespace ‘std’ does not name a template type template <size_t... Idx> using index_list = std::index_sequence<Idx...>; ^~~~~~~~~~~~~~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:6:54: error: ‘make_index_sequence’ in namespace ‘std’ does not name a template type template <size_t N> using make_index_list = std::make_index_sequence<N>; ^~~~~~~~~~~~~~~~~~~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:11:63: error: type/value mismatch at argument 1 in template parameter list for ‘template<class ... Ts> struct meta::type_list’ template <size_t... Idx> struct to_type_list<type_list<Idx...>> { using type = type_list<size_t_t<Idx>...>; }; ^~~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:11:63: note: expected a type, got ‘Idx ...’ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:11:66: error: template argument 1 is invalid template <size_t... Idx> struct to_type_list<type_list<Idx...>> { using type = type_list<size_t_t<Idx>...>; }; ^~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:13:82: error: type/value mismatch at argument 1 in template parameter list for ‘template<class IList> struct meta::to_type_list’ template <size_t N> using make_index_type_list = to_type_list_t<to_type_list<N>>; ^ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:13:82: note: expected a type, got ‘N’ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:13:83: error: template argument 1 is invalid template <size_t N> using make_index_type_list = to_type_list_t<to_type_list<N>>; ^~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:16:115: error: type/value mismatch at argument 1 in template parameter list for ‘template<class List> struct meta::to_index_list’ template <size_t... Idx> struct to_index_list<type_list<size_t_t<Idx>...>> { using type = to_index_list<Idx...>; }; ^ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:16:115: note: expected a type, got ‘Idx’ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:16:115: note: so any instantiation with a non-empty parameter pack would be ill-formed /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:40:68: error: type/value mismatch at argument 1 in template parameter list for ‘template<class List> struct meta::to_index_list’ struct nth_type_impl<type_list<Ts...>, to_index_list<Idx...>, N> : indexed_type<Idx, Ts>... {}; ^ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:40:68: note: expected a type, got ‘Idx’ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:40:68: note: so any instantiation with a non-empty parameter pack would be ill-formed /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:40:72: error: template argument 2 is invalid struct nth_type_impl<type_list<Ts...>, to_index_list<Idx...>, N> : indexed_type<Idx, Ts>... {}; ^ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:47:80: error: type/value mismatch at argument 1 in template parameter list for ‘template<class List> struct meta::to_index_list’ detail::nth_type_impl<type_list<Ts...>, to_index_list<sizeof...(Ts)>, N>{})); ^ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:47:80: note: expected a type, got ‘sizeof... (Ts)’ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:47:84: error: template argument 2 is invalid detail::nth_type_impl<type_list<Ts...>, to_index_list<sizeof...(Ts)>, N>{})); ^ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:53:43: error: type/value mismatch at argument 1 in template parameter list for ‘template<class List> struct meta::to_index_list’ struct at_list<List, to_index_list<Idx...>> { using type = type_list<at_t<List, Idx>...>; }; ^~~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:53:43: note: expected a type, got ‘Idx’ /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:53:43: note: so any instantiation with a non-empty parameter pack would be ill-formed /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:53:46: error: template argument 2 is invalid struct at_list<List, to_index_list<Idx...>> { using type = type_list<at_t<List, Idx>...>; }; ^~ In file included from /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:3: /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:77:48: error: type/value mismatch at argument 1 in template parameter list for ‘template<class T> struct meta::is_type_list’ using repeat_t = transform_t<is_type_list<N>, bind_front<first, T>::template result_t>; ^ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:77:48: note: expected a type, got ‘N’ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:77:90: error: template argument 1 is invalid using repeat_t = transform_t<is_type_list<N>, bind_front<first, T>::template result_t>; ^ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:83:30: error: type/value mismatch at argument 1 in template parameter list for ‘template<class T> struct meta::is_type_list’ is_type_list<Size>, bind_front<plus, size_t_t<Begin>>::template result_t>>; ^ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:83:30: note: expected a type, got ‘Size’ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:83:77: error: template argument 1 is invalid is_type_list<Size>, bind_front<plus, size_t_t<Begin>>::template result_t>>; ^~~~~~~~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:83:85: error: template argument 1 is invalid is_type_list<Size>, bind_front<plus, size_t_t<Begin>>::template result_t>>; ^~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:86:46: error: ‘index_range’ is not a member of ‘meta::detail’ using subseq_t = at_list_t<List, detail::index_range<Begin, Size>>; ^~~~~~~~~~~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:86:65: error: wrong number of template arguments (3, should be 2) using subseq_t = at_list_t<List, detail::index_range<Begin, Size>>; ^~~~ In file included from /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:2, from /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:3: /home/wz18207/CLionProjects/Meta Algotirhm/meta/list.h:54:99: note: provided for ‘template<class List, class IList> using at_list_t = typename meta::at_list::type’ template <typename List, typename IList> using at_list_t = typename at_list<List, IList>::type; ^ In file included from /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:3: /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:93:27: error: type/value mismatch at argument 1 in template parameter list for ‘template<class T> struct meta::is_type_list’ is_type_list<N>, bind_front<minus, size_t_t<N - 1>>::template result_t>>; ^ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:93:27: note: expected a type, got ‘N’ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:93:75: error: template argument 1 is invalid is_type_list<N>, bind_front<minus, size_t_t<N - 1>>::template result_t>>; ^~~~~~~~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:93:83: error: template argument 1 is invalid is_type_list<N>, bind_front<minus, size_t_t<N - 1>>::template result_t>>; ^~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:95:72: error: ‘rev_ilist’ is not a member of ‘meta::detail’ template <typename List> using reverse_t = at_list_t<List, detail::rev_ilist<List::size>>; ^~~~~~~~~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:95:88: error: type/value mismatch at argument 2 in template parameter list for ‘template<class List, class IList> using at_list_t = typename meta::at_list::type’ template <typename List> using reverse_t = at_list_t<List, detail::rev_ilist<List::size>>; ^~~~ /home/wz18207/CLionProjects/Meta Algotirhm/meta/algorithm.h:95:88: note: expected a type, got ‘(<expression error> < List::size)’ /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp: In function ‘int main(int, char**)’: /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:10:17: error: ‘renameat’ does not name a type using Rep = renameat::repeat<void, 10000>; ^~~~~~~~ /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:11:39: error: ‘Rep’ was not declared in this scope constexpr bool v = meta::all_of_v<Rep, std::is_void>; ^~~ /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:11:30: error: template argument 1 is invalid constexpr bool v = meta::all_of_v<Rep, std::is_void>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:12:32: error: type/value mismatch at argument 1 in template parameter list for ‘template<class List, class T> constexpr const size_t meta::count_v<List, T>’ constexpr size_t c = meta::count_v<Rep, void>; ^~~~~~~~~~~~~~~~~~ /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:12:32: note: expected a type, got ‘Rep’ /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:13:25: error: no matching function for call to ‘print_typename<Rep>()’ print_typename<Rep>(); ^ /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:5:6: note: candidate: ‘template<class T> void print_typename()’ void print_typename(){ ^~~~~~~~~~~~~~ /home/wz18207/CLionProjects/Meta Algotirhm/main.cpp:5:6: note: template argument deduction/substitution failed: make[3]: *** [CMakeFiles/Meta_Algotirhm.dir/build.make:63:CMakeFiles/Meta_Algotirhm.dir/main.cpp.o] 错误 1 make[2]: *** [CMakeFiles/Makefile2:76:CMakeFiles/Meta_Algotirhm.dir/all] 错误 2 make[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/Meta_Algotirhm.dir/rule] 错误 2 make: *** [Makefile:118:Meta_Algotirhm] 错误 2
如果可以的话,能告诉我关于该工程的makefile应该怎么写好呢,真的非常感谢!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.