C++0x adds hash<...>(...).
I could not find a hash_combine function though, as presented in boost. What is the cleanest way to implement something like this? Perhaps, using C++0x xor_combine?
I'd like to use searchlogic's scope_procedure feature like so
class MyModelObject < ActiveRecord::Base
scope_procedure :my_scope_proc, lambda { |p1, p2| { :conditions => "p1 >= #{p1} AND p2 < #{p2}" }}
end
Then, I am doing the search:
scope = MyModelObject.search(:my_scope_proc => true)
scope.all
The above code obviously doesn't work because I didn't pass p1 and p2 parameters to my named scope.
I can't figure out how to pass parameters to the named scope.
is there some way to embed pragma statement in macro with other statements?
I am trying to achieve something like:
#define DEFINE_DELETE_OBJECT(type) \
void delete_ ## type_(int handle); \
void delete_ ## type(int handle); \
#pragma weak delete_ ## type_ = delete_ ## type
I am okay with boost solutions (save for wave) if one exists.
thank you
How can I translate this SQL into a named_scope? Also, I want the total comments param to be passed through a lambda.
"select users., count() as total_comments from users, comments where (users.id = comments.user_id) and (comments.public_comment = 1) and (comments.aasm_state = 'posted') and (comments.forum_user_id is null) group by users.id having total_comments 25"
Hi. I'm writing a game in C++, and I'm trying to get it to recognize keyboard and mouse events. Google tells me that boost.signal is suitable for event handling, but none of the code samples or tutorials I've found tell me how to associate a keypress or mouseclick with a function. Can anyone shed any light on this?
The .NET framework provides a few handy general-use delegates for common tasks, such as Predicate<T> and EventHandler<T>.
Is there a built-in delegate for the equivalent of CompareTo()?
The signature might be something like this:
delegate int Comparison<T>(T x, T y);
This is to implement sorting in such a way that I can provide a lambda expression for the actual sort routine (ListView.ListViewItemSorter, specifically), so any other approaches welcome.
I have some experience with C#, and would like to improve my knowledge of its latest improvements. I am in the middle of reading and enjoying "Effective C#" by Bill Wagner right now. However, I would appreciate more examples, especially with lambda expressions and such.
Any suggestions are greatly appreciated. High quality resources are preferable, and it does not matter much if they are free or not.
Is there a representation of a graph in Java standard libraries, like there is in the boost library in C++? Is there a graph representation which is a standard in the business?
hello.
Is it possible to specify alignment of parent class?
for example something like (which does not compiled):
template<size_t n>
class Vector : public boost::array<double,n> __attribute__ ((aligned(16)))
{
thanks
I have a bit of free time at work and was wondering, what are some hard applications to build but which are not big?
Hopefully nothing which requires specialist knowledge but something nonetheless hard and which will boost my coding/problem-solving skills.
Thanks
I have a list which contains a number of things:
lista = ['a', 'b', 'foo', 'c', 'd', 'e', 'bar']
I'd like to get the first item in the list that fulfils a predicate, say len(item) > 2. Is there a neater way to do it than itertools' dropwhile and next?
first = next(itertools.dropwhile(lambda x: len(x) <= 2, lista))
I did use [item for item in lista if len(item)>2][0] at first, but that requires python to generate the entire list first.
I wish to test the new features that will came with the next JDK like project coin, project lambda etc. but the last JDK 7 to download will not have any already implemented!
From which build can I test them?
I think it's incredible that, now in may 2010 at few months to the official final release (november 2010????) for we developers there is no possibility to test any of this features!!
I wish to test the new features that will came with the next JDK like project coin, project lambda etc. but the last JDK 7 to download will not have any already implemented!
From which build can I test them?
I think it's incredible that, now in may 2010 at few months to the official final release (november 2010????) for we developers there is no possibility to test any of this features!!
hello.
I have ran into yet another problem I do not understand.
The following does not instantiate, why?
template<class E>
void operator[](typename boost::mpl::identity<E>::type e) const;
thank you for your help
Given the following method: (real method has a few more parameters, but the important ones are below...)
public string DoSomething(string formatter, params string[] values)
{
// Do something eventually involving a call to String.Format(formatter, values);
}
Is there a way to tell if my values array has enough objects in it to cover the formatter, so that I can throw an exception if there aren't (short of doing the string.Format; that isn't an option until the end due to some lambda conversions)?
Quick and simple question.
There are examples online about achieving in-memory gzip compression with zlib (C++) WITHOUT external libraries (like boost or such)?
I just need to compress and decompress a block of data without much options. (it must be gzip as its the same format used by another mine C# program (the data is to be shared))
Tried to search to no avail...
Thanks!
To prohibit copy construction and copy assignment, I've seen the boost noncopyable class and in the Google style guide the DISALLOW_COPY_AND_ASSIGN macro. Is there any reason to prefer one of the techniques over the other, or any subtle differences one should be aware of?
A class has a constructor which takes one parameter:
class C(object):
def __init__(self, v):
self.v = v
...
Somewhere in the code, it is useful for values in a dict to know their keys.
I want to use a defaultdict with the key passed to newborn default values:
d = defaultdict(lambda : C(here_i_wish_the_key_to_be))
Any suggestions?
So, I want to be able to modify already instanced C++ objects in a scripting language. I have been looking at Lua with LuaBind and Python with SWIG or Boost::Python, but all I see is how to make new instances of the objects, but I want to modify already existing ones.
Example:
C++:
Player playerOne = new Player();
Scripting Language :
playerOne.Transform.x += 5;
Is this possible, and if so, wat would you suggest as a good Language/library to achieve this with?
i am using a function that receives ostream but i have wostream is there a way to convert one to the other?
in particular i want to use boost::write_graphviz which takes ostream but i currently in << operator for wostream.
I'm trying to make has_many relation with dynamic class_name attribute
class Category < ActiveRecord::Base
has_many :ads, :class_name => ( lambda { return self.item_type } )
end
or
class Category < ActiveRecord::Base
has_many :ads, :class_name => self.item_type
end
But i got errors:
can't convert Proc into String
or
undefined method `item_type' for #<Class:0xb62c6c88>
Thank you for any help!
I need to open a file as ofstream and write to the front of the file, while preserving
the remaining contents of the file, which will be "moved". Similar to "prepend"
a file.
Is this possible using the STL or boost ?
If I have a class that contains a std::list<Foo>, how can I implement iterators to a Foo* collection, preferably without using boost?
I'd rather not maintain a parallel collection of pointers. For now I have std::list<Foo>, mostly so that removing or inserting an element does not invalidate all other iterators, but would it be possible to implement other iterators too, so that the collection type used in the implementation is opaque to the user of the class?