-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmetaprimes.cpp
More file actions
79 lines (57 loc) · 1.96 KB
/
Copy pathmetaprimes.cpp
File metadata and controls
79 lines (57 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/***************************************************************************
* Copyright (C) 2015 by Vladimir Mirnyy, blog.scpp.eu *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the MIT License *
***************************************************************************/
/** \file
\brief Program to demonstrate compile-time primes list generation
*/
#include <iostream>
#include <limits>
#include "sint.h"
#if !defined(LIMIT) || (LIMIT == 0)
static const ulong_t N = 1000;
#else
static const ulong_t N = LIMIT;
#endif
#ifndef MODE
#define MODE 1
#endif
#if !defined(CPP) || CPP != 11
#include "metafactor.h"
#include "metaprimes.h"
// Top 3 compile-time generation implementations (for gcc 5.4)
#if MODE == 1
typedef F210K::GeneratePrimesWithList<N>::Result PrimesList;
#elif MODE == 2
typedef F30K::GeneratePrimesWithList<N>::Result PrimesList;
//typedef F30K::Sieve<N>::Result PrimesList;
#elif MODE == 3
typedef F6K::GeneratePrimesWithList<N>::Result PrimesList;
//typedef F6K::Sieve<N>::Result PrimesList;
#endif
#else // c++11 or higher
#include "metafactor11.h"
#include "metaprimes11.h"
// Top 3 compile-time generation implementations (for gcc 5.4)
// They are generally slower than without c++11 above
#if MODE == 1
typedef F210K::GeneratePrimesWithList<N>::type PrimesList;
#elif MODE == 2
typedef F30K::GeneratePrimesWithList<N>::type PrimesList;
#elif MODE == 3
typedef F6K::GeneratePrimesWithList<N>::type PrimesList;
#endif
#endif
int main(int argc, char *argv[])
{
typelist_out<PrimesList>::print(std::cout, '\t');
// std::cout << Loki::TL::Length<PrimesList>::value << std::endl;
std::cout << "Check ... ";
// Run-time check of the list
if (CheckPrimesListAtRunTime<PrimesList>::apply())
std::cout << "Ok!" << std::endl;
//std::cin.get();
return 0;
}