LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-14-2019, 08:06 PM   #1
huaihaizi3
LQ Newbie
 
Registered: Oct 2009
Location: BeiJing China
Distribution: Fedora
Posts: 18

Rep: Reputation: 0
Thumbs up Monster - Advanced C++ Template MetaProgramming Framework


https://github.com/deepgrace/monster
Code:
#include <monster.hpp>
using namespace monster;

int main(int argc, char* argv[])
{
    // Knuth–Morris–Pratt (KMP) algorithm searches for occurrences of a sequence within another sequence
    using k1 = kmp_t<std::tuple<int, char, int>, std::tuple<int, int, char, int, char, int, char, int>>;
    using k2 = kmp_t<std::integer_sequence<int, 7, 5>, std::integer_sequence<int, 7, 5, 4, 0, 7, 5, 9>>;
    static_assert(std::is_same_v<k1, std::index_sequence<1, 3, 5>>);
    static_assert(std::is_same_v<k2, std::index_sequence<0, 4>>);

    // find K-th smallest element in a sequence (k == 2)
    using min1 = select_t<2, std::tuple<short, int, double, int, char>>;
    using min2 = select_t<2, std::integer_sequence<int, -2, 1, 0, -7, 4, 3>>;
    static_assert(std::is_same_v<min1, short>);
    static_assert(std::is_same_v<min2, int_<-2>>);

    // find K-th greatest element in a sequence (k == 2)
    using max1 = select_t<2, std::tuple<short, int, double, int, char>, greater_equal_t>;
    constexpr auto max2 = select_v<2, std::integer_sequence<int, -2, 1, 0, -7, 4, 3>, greater_equal_t>;
    static_assert(std::is_same_v<max1, int>);
    static_assert(max2 == 3);

    return 0;
}
 
Old 08-16-2019, 01:01 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,844

Rep: Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320Reputation: 1320
It does sound cool.
 
  


Reply

Tags
c++, sort, template, type


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Python Metaprogramming Decorators Make Magic Easy LXer Syndicated Linux News 0 01-18-2007 08:33 AM
LXer: A look at the newest Python Metaprogramming LXer Syndicated Linux News 0 01-09-2007 03:54 PM
LXer: Template Monster Launches New PHP Site LXer Syndicated Linux News 0 04-27-2006 02:33 AM
LXer: The Art of Metaprogramming using Scheme LXer Syndicated Linux News 0 02-03-2006 03:16 PM
Template class with a template member... Nicholas Bishop Programming 3 02-21-2005 08:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration