Assume you have a type like the following:
struct Value(int v_)
{
static const v = v_:
}
How would you sort a list of these types, assuming an interface something like this:
alias Sorted!(Value!(4), Value!(2), Value!(1), Value!(3)) SortedValues;
You may use D 2.x features if it makes for a better solution, but please state if you...
I'm currently trying to move a web project from a custom i18n system to gettext, however I'll need to prepare HTML::Template::Compiled templates for i18n too and don't know yet how to do it. My templates are stored in separate files, therefore I can't use Perl's string interpolation and I also would like to use gettext-typical _() syntax...
Basically, I have a list of colors and a defined datatemplate for listbox item:
<DataTemplate x:Key="colorItemDataTemplate">
<Border x:Name="borderInner" BorderBrush="Black" BorderThickness="1" Background="{Binding Brush}" Width="11" Height="11" />
</DataTemplate>
Now, when I add a bunch of items into the listbox and then set the ...
consider the following algorithm with arrays:
class MyType;
{
// some stuff
}
class MySubType:MyType
{
// some stuff
}
void foo(MyType** arr, int len)
{
for (int i = 0;i<len;i++)
// do something on arr[i]->
}
void bar()
{
MySubType* arr[10];
// initialize all MySubType*'s in arr
foo(&arr, 10);
}
Noth...
Hello there
I'm writing a parallel evolutionary algorithm library using C++, MPI and CUDA. I need to extract the raw data from my object oriented design and stick it into a flat array (or std::vector using stl-mpi) for it to be sent across to nodes or the cuda device.
The complete design is quite complex with a lot of inheritance to k...
I am trying to use std::for_each to output the contents of vectors, which may contain different types. So I wrote a generic output function like so:
template<typename T> void output(const T& val)
{
cout << val << endl;
}
which I would like to use with:
std::for_each(vec_out.begin(), vec_out.end(), output);
but the compiler comp...
Template metaprogramming can be used for computing things like factorial at compile time instead of during runtime. I've heard that some programming contests have introduced limitations on compilation time exactly to weed out template metaprogramming abuse.
Is there any innocent looking example of using templates that takes some really-...
I've created a two-worksheet template in Excel - the first sheet is for pretty charts, and the other sheet is for the data that drives those charts. I've written a vb.net 2005 app that can dump in all my data on the second worksheet, and the chart worksheet updates perfectly.
I would like to do this report several times over in the sam...
The problem is pretty basic.
(I am puzzled why the search didn't find anything)
I have a rectangular "picture" that stores it's pixel color line
after line in a std::vector
I want to copy a rectangular region out of that picture.
How would I elegantly code this in c++?
My first try:
template <class T> std::vector<T> copyRectFr...
I have a ComboBox and I have set the combo.ItemsSource property to a List object. The Book class contains two properties: "Abbreviation" and "Name".
I have set the ComboBox's DisplayMemberPath to "Abbreviation" but the following style that is set on the ComboBox does not display the Abbreviation property, but instead shows "Words.Book" ...
I'm creating word documents from templates (.dot) via Microsoft.Office.Interop.Word. The code below works on some templates but not on others: where it doesn't work it throws an RPC_E_SERVERFAULT exception. What is this about, what can be the cause and how could i fix it? (exception occurs at the second line)
Code:
w...
Hello all,
Am trying to move an antique C++ code base from gcc 3.2 to gcc 4.1, as I have run into a few issues. Of all the issues, the following is left me clueless (I guess I spent too much time with Java or I might have forgotten the basics of C++ :-P ).
I have a template class
template < class T > class XVector < T >
{
...
te...
We all know the usual use of templates to design containers and we all know that you can do things with templates that will make your head spin.
When I first encoutered static polymorphism I was really struck on what you can do with templates. It's obvious that templates are useful for more than for designing containers. I bought Andrei...
I have grown tired of all the little issues with paste template, it's horrible to maintain the templates, it has no way of updating an old project and it's very hard to test.
I'm wondering if someone knows of an alternative for quickstart generators as they have proven to be useful.
...
I have a space separated file which contains some key->value pairs. These are to be loaded to a structure of the type given below:
#define FV_PARAM1 "A"
#define FV_PARAM2 "B"
parameter_t & parameterFeatureVector (
parameter_t & param,
int param1,
int param2,
) {
param.addParam(FV_PARAM1, par...
I'm using NVelocity to build an email message. Rather than mark every reference as quiet ($!name instead of $name), I'd like to default to quiet references.
Is it possible?
...
A view I am using returns a string to a html template. The string which is returned contains special characters which are not represented correctly in the template. To put it simply a string which is returned from the view might look like this:
test = "\"Foo bar\""
return render_to_response('index.html', {'test': test})
And is displ...
I've got a project template which I want to appear under both "Visual C#" and its subtype "Test". I can get it to appear in one but not the other by placing it in
\Visual Studio 2008\Templates\ProjectTemplates\Visual C#
and
\Visual Studio 2008\Templates\ProjectTemplates\Visual C#\Test
respectively.
I've tried setting the following attr...
I'm new to C++ Templates, and am finding it hard to understand and debug them. What are some good resources for doing both/either?
...
Sometimes it works sometimes not:
template <class T>
void f(T t) {}
template <class T>
class MyClass {
public:
MyClass(T t) {}
};
void test () {
f<int>(5);
MyClass<int> mc(5);
f(5);
MyClass mc(5); // this doesn't work
}
Is there a way to hack around the example above? I.e. force the compiler to infer the template paramete...