template-meta-programming Questions
1
I see two possible styles for implementing type lists in C++11/14 and I was curious if there's any reason to prefer one over the other. The first technique is outlined here and models itself on Boo...
Attract asked 12/6, 2015 at 18:4
3
To illustrate, say I have a custom container than makes use of the STL std::vector internally. If I typedef std::vector<char*>::iterator to my_container::iterator, then dereferencing the iter...
Aulic asked 21/5, 2015 at 11:18
3
Solved
If this is a duplicate I apologize. I looked around and found similar issues but nothing exactly like this.
If I instantiate a template like so...
MyClass<int[10]> c;
How can I write the ...
Liz asked 1/6, 2015 at 15:20
2
I have a project which uses quite a bit of C++ template meta-programming. This makes compile times long. I understand that I cannot have the cake and eat it too but I would like to know some tips a...
Alterant asked 20/4, 2015 at 20:26
5
Solved
So, what I want is to create multidimensional vector of given type where the first dimension will have size of the first argument of a function call, etc, for example if I do
std::size_t n = 5;
au...
Rienzi asked 1/5, 2015 at 21:47
2
Solved
Update
I posted a working rough draft of rebind as an answer to the question. Though I didn't have much luck finding a generic way to keep static_asserts from breaking metafunctions.
Basically ...
Primer asked 24/3, 2015 at 4:1
2
Solved
I want a function that will behave like std::transform for tuples. Basically the functionality to be implemented is
template<size_t From, size_t To, class Tuple, class Func>
void tuple_trans...
Heptavalent asked 23/4, 2015 at 10:1
1
Solved
I have a type trait that checks if a given type is an instance of a given class template:
template <template <typename...> class C, typename T>
struct check_is_instance_of : std::false...
Badenpowell asked 30/3, 2015 at 8:57
2
Is it possible to determine the function type of the candidate that overload resolution would select given an overload set and an argument list? For example, given:
char* f(int);
int f(char*);
I...
Lucknow asked 26/2, 2015 at 2:33
2
Solved
Is there any examples out there where template metaprogramming would be better to use than the new constexpr? From what I've understood, both constexpr and template metaprogramming have similar pur...
Pizor asked 28/3, 2015 at 21:39
1
Solved
Assume I have a template class TemplateClass with a template function templFcn as follows:
template <typename T>
struct TemplateClass {
template <bool Bool> void templFcn(int i)...
Dribble asked 7/3, 2015 at 13:32
4
I would like to wrap member functions that conform to the type 'void (ClassType::Function)(ArgType)' with a templated class. Later, I want to pass an instance of ClassType to an instance of this te...
Loggins asked 9/2, 2013 at 1:15
1
Solved
I'm using FLTK to do my GUI related stuff, and it requires functions of type void (*fn)( Fl_Widget*, void* ) to be registered as widget callbacks. I'm tired of creating function forwarders by hand ...
Doody asked 1/3, 2015 at 10:21
1
In modding a closed-source game I'm modifying the machine code at runtime to jmp into my own code. To do this in a generic manner I'm using pattern matching to find the code locations I want to mod...
Cyanamide asked 22/12, 2014 at 22:27
2
Is it possible using macro magic or TMP to insert the length into a string at compile time?
For example:
const wchar_t* myString = L"Hello";
I would want the buffer to actually contain "[length...
Payola asked 28/11, 2013 at 11:12
4
Solved
I'm working on a C++ project with extensive compile-time computations. Long compilation time is slowing us down. How might I find out the slowest parts of our template meta-programs so I can optimi...
Almetaalmighty asked 4/4, 2013 at 17:54
2
Solved
Is there anyway to specialize a template like this, making the specialization apply only if T has a member function hash? (Note this is only an example of what I am trying to do. I know that it wou...
Logway asked 19/6, 2012 at 19:5
3
Solved
I have 100 or so trampoline functions. I would like to know whether it is possible to automate wrapping each one inside a try/catch block.
Please be warned in advance, this is not an easy question...
Strasbourg asked 7/1, 2015 at 13:58
2
Solved
I'm trying to utilize the ODE integration capabilities of Boost using the Matrix class from Eigen 3 as my state vector, but I'm running into problems deep into Boost that I don't understand how to ...
Latitudinarian asked 1/4, 2014 at 9:47
2
Solved
Is it possible to do something like the following that compiles without template specialization?
template <class T>
class A {
public:
#if std::is_same<T, int>
void has_int() { }
#el...
Lazare asked 16/12, 2014 at 12:4
3
Solved
I am trying to solve the Towers of Hanoi at compile-time, but I have discovered a problem:
template<int src, int dst>
struct move_disc
{
// member access will print src and dst
};
template...
Varion asked 8/11, 2013 at 17:19
1
Solved
I have written a metafunction to retrieve the type of the first parameter of a member function, which of course receives one or more parameters. The code I have written is as follow:
template <...
Skiffle asked 26/11, 2014 at 21:28
2
Solved
Coming from C++, I'm trying to do some metaprogramming in Swift. For example, I'd like to implement a metafunction that adds two numbers. I've tried something like this:
protocol IntWrapper {
cla...
Partlow asked 14/11, 2014 at 21:46
5
Solved
PREMISE:
After playing around with variadic templates a little bit, I realized that achieving anything which goes slightly beyond the trivial meta-programming tasks soon becomes pretty cumbersome....
Intoxication asked 10/1, 2013 at 15:19
2
Solved
I am not sure if the title is correct but here is my problem/question:
I would like to use metaprogramming in order to create functions for a specific expression. For example lets say that we have...
Ronald asked 31/10, 2014 at 18:56
© 2022 - 2024 — McMap. All rights reserved.