Background
This is for a memory manager in a game engine. I have a freelist implemented, and would like to have a compile-time list if these. (A MPL or Fusion vector, for example). The freelist's correspond to allocation sizes, and when allocating/deallocating objects of size less than a constant, they will go to the corresponding freel...
I'm trying to implement a domain class that records when any property's value was changed, but my setProperty() call results in infinite recursion when setting the actual value.
This is how it looks right now:
void setProperty(String name, value)
{
if(name == "modified")
{
this.modified = value
return
}
...
I have read in few different places that using c++0x's new string literals it might be possible to compute a string's hash at compile time. However, no one seems to be ready to come out and say that it will be possible or how it would be done.
Is this possible?
What would the operator look like?
I'm particularly interested use cas...
I have just read Python Cookbook. The book is amazing.
I think the best use of this book is that it provides lots of examples that show python in real problem applications. Many of the idioms include metaprogramming techniques.
I wonder if there is any catalog that summarizes metaprogramming idioms in Python?
Python Cookbook is very ...
I was wondering if C++0x provides any built-in capabilities to check if a parameter pack of a variadic template contains a specific type. Today, boost:::mpl::contains can be used to accomplish this if you are using boost::mpl::vector as a substitute for variadic templates proper. However, it has serious compilation-time overhead. I suppo...
Basically, I am looking for a library solution that does this:
#include <boost/type_traits.hpp>
template<bool>
struct bool_to_bool_type;
template<>
struct bool_to_bool_type<false>
{
typedef boost::false_type type;
};
template<>
struct bool_to_bool_type<true>
{
typedef boost::true_type type;
};
Is there such a metafunction?
...
Hello guys,
I'm using appengine to develop an application. Ideally I would like to define a new kind (called Recipe) like this:
class Recipe(db.Model):
ingredients = db.ListProperty(type)
quantities = db.ListProperty(int)
However it seems that you cannot use "type" as the class value in ListProperty. I was thinking of instead ...
I need some idea how to write a C++ cross platform implementation of a few parallelizable problems in a way so I can take advantage of SIMD (SSE, SPU, etc) if available. As well as I want to be able at run time to switch between SIMD and not SIMD.
How would you suggest me to approach this problem?
(Of course I don't want to implement th...
I just found out how to check if operator<< is provided for a type.
template<class T> T& lvalue_of_type();
template<class T> T rvalue_of_type();
template<class T>
struct is_printable
{
template<class U> static char test(char(*)[sizeof(
lvalue_of_type<std::ostream>() << rvalue_of_type<U>()
)]);
template<class U> sta...
Snippet 1:
module A
def cm(m,ret)
class_eval do
define_method(m.to_sym) do
return ret
end
end
end
end
and snippet 2:
module B
def cm(m,ret)
class_eval do
"def #{m} #{ret} end"
end
end
end
The methods defined in these modules are to be used to create methods on a class, that returns cer...
I'm trying to add logging to a method from the outside (Aspect-oriented-style)
class A
def test
puts "I'm Doing something..."
end
end
class A # with logging!
alias_method :test_orig, :test
def test
puts "Log Message!"
test_orig
end
end
a = A.new
a.test
The above works alright, except that if I ever needed to do...
In Ruby, we could use super within singleton method to call the corresponding super class's singleton method, like the following code shows.
class Base
def self.class_method
puts "Base class method"
end
end
class Derived < Base
def self.class_method
puts "Derived class method"
super
end
end
Derived.class_method
# D...
Hello there,
I'm trying to make an API for dynamic reloading processes; right now I'm at the point where I want to provide in all contexts a method called reload!, however, I'm implementing this method on an object that has some state (so it can't be on Kernel).
Suppose we have something like
WorkerForker.run_in_worker do
# some cod...
Hello,
I am coding a small GUI with netbeans and I am using objects from the Palette Manager.
I have created a very simple application. Just a JLabel and a JTextArea. A small image
here http://cateof.wordpress.com/2010/01/27/example-overflow/ (one image better than 1000 lines of code)
I am looking for a "meta programming" idea for my G...
Hi,
I'm developing a plugin that adds a getFlashHelper method to each controller. This method should return an instance of a FlashHelper class.
However, the constructor of the FlashHelper class must be passed the instance of the controller on which the getFlashHelper method was called.
Hopefully the following code will explain what I'...
I think meta programming is very very cool. In particular, I love lisp macros.
However, I think C++ template suck because:
1) they slow down compile time (even with precompiled headers that end up being 50MB big if you include any of he STL stuff).
2) they give terrible compiler/syntax errors that are counintuitive
3) they weren't desin...
Hi,
I was trying to 'extend' a closed class
collections.defaultdict(lambda: 1)
by addint it 2 methods, called 'vocabulary', and 'wordcount'
apparently it's impossible to setattr method to builin types, nor can I inherit from defaultdic, so I decided to write a class and redirect calls to it to the type I want to extend.
class BagOfW...
I'm wondering what the difference is between using a static const and an enum hack when using template metaprogramming techniques.
EX: (Fibonacci via TMP)
template< int n > struct TMPFib {
static const int val =
TMPFib< n-1 >::val + TMPFib< n-2 >::val;
};
template<> struct TMPFib< 1 > {
static const int val = 1;
};
template<>...
So, this question has been asked before, but I wanted a question with some of those key words in the title.
The issue is simple: How can I have a templated class, such that for each instance of the template - but not each instance of the class - there is a unique, numerical identifier?
That is, a way to differentiate:
foo<int> f1;
foo...
I've just started looking at a project that has >20k unit tests written in Rspec (the project itself isn't written in Ruby; just the test cases). The current number of test cases is expected to grow dramatically in the future, as more functionality is added. What's already happened (over an extended period) is that RSpec started out be...