I need to write a templated function replace_all in C++ which will take a string, wstring, glibmm::ustring etc. and replace all occurrences of search in subject with replace.
replace_all.cc
template < class T >
T replace_all(
T const &search,
T const &replace,
T const &subject
) {
T result;
type...
Here's the scenario
I created a Site which in I used custom lists, webparts, custom developed webparts, workflows et cetera. You can see the site as an application.
What I am trying to do is to create a solution package which holds everything I build in that site so that I can give the solution file to an sharepoint administrator who ...
It is a university task in my group to write a compiler of C-like language. Of course I am going to implement a small part of our beloved C++.
The exact task is absolutely stupid, and the lecturer told us it need to be self-compilable (should be able to compile itself) - so, he meant not to use libraries such as Boost and STL. He also do...
I'm working on a site that will send out a significant number of emails. I want to set up both header and footer text, or maybe even templates to allow the users to easily edit these emails if they need to.
If I embed the HTML inside C# string literals, it's ugly and they would have to worry about escaping. Including flat files for the...
I tried three iterations of the following simple program. This is a highly simplified attempt to write a container-and-iterator pair of classes, but I was running into issues with incomplete types (forward declarations). I discovered that this was in fact possible once I templatized everything - but only if I actually used the template...
What is the relationship between using virtual functions and C++ inheritance mechanisms versus using templates and something like boost concepts?
It seems like there is quite an overlap of what is possible. Namely, it appears to be possible to achieve polymorphic behavior with either approach. So, when does it make sense to favor one ov...
How can you access WPF's built-in styles/templates?
For example I'm trying to move the NavigationWindow's chrome to the bottom of the window. I've seen Microsoft's NavigationWindow template example but it is quite verbose and doesn't reuse the default navigation chrome.
I've also tried looking at the tree inside Snoop. All the chrome ...
I'm using C++ templates to pass in Strategy functors to change my function's behavior. It works fine. The functor I pass is a stateless class with no storage and it just overloads the () operator in the classic functor way.
template <typename Operation> int foo(int a)
{
int b=Operation()(a);
/* use b here, etc */
}
I do this often, a...
Hey,
I've been talking with friends and some completely agree that templates in C++ should be used, others disagree entirely.
Some of the good things are:
They are more safe to use (type safety).
They are a good way of doing generalizations for APIs.
What other good things can you tell me about C++ templates?
What bad things can y...
We're planning on setting up a website for student group - most of the content is fairly static but certain portions such as events and members would turn up from the database. I've never worked with PHP much, and was wondering would a CMS system like Drupal or PHP Nuke be appropriate for this kinda work?
Is there anything else that wo...
Hey,
I am trying to compile this :
template <class T, class U = myDefaultUClass<T> >
class myClass{
...
};
Although it seems quite intuitive to me it is not for my compiler, does anyone knows how to do this ?
edit : Ok, the problem was not actually coming from this but from a residual try ... Sorry about this, thanks for your ans...
We are developing a huge website, it will get lots of traffic, right now we are analyzing our options and Smarty looks nice but i have seen lots of flames about this, some love it some hate it.
What do you think?
Any real life experience with Smarty?
If you hate it please write the reasons, same thing if you love it. ;)
Advice about al...
I'm messing around with rails 2.3 templates and want to be able to use the app name as a variable inside my template, so when I use...
rails appname -m path/to/template.rb
...I want to be able to access appname inside template.rb. Anyone know how to do this?
Thanks
...
I feel like this one has been asked before, but I'm unable to find it on SO, nor can I find anything useful on Google. Maybe "covariant" isn't the word I'm looking for, but this concept is very similar to covariant return types on functions, so I think it's probably correct. Here's what I want to do and it gives me a compiler error:
c...
Hi,
I am working on a game and have an interesting question. I have some game-wide constant values that I want to implement in one file. Right now I have something like this:
constants.cpp
extern const int BEGINNING_HEALTH = 10;
extern const int BEGINNING_MANA = 5;
constants.hpp
extern const int BEGINNING_HEALTH;
extern const int B...
I have a custom control which includes a property of the following definition:
[PersistenceMode(PersistenceMode.InnerProperty)]
public ITemplate Template {
get { return template; }
set { template = value; }
}
The control overrides CreateChildControls(), and adds several HtmlGenericControls and an asp:Panel control.
The actual ac...
I have a situation where I need to know the current color of an alternating row in a TemplateField of a GridView.
UPDATED:
How do I retrieve this Color value in a <%# ??? %>.
(Or an workaround where I get the row number).
...
If you are using a template in C++ that takes an integer value as a parameter, are there any requirements on an integer variable used as the parameter that are different than if the variable was used as a parameter in a function call?
This is a follow-up to question here . I specifically want to address if there is a difference WRT v...
I have a problem I don't really understand. I have a class Node.
template<class T>
class node {
protected:
T _data;
public:
node(T data);
};
This is in "node.h" file. In "node.cpp" file, there is this constructor:
#include "node.h"
template<class T>
node<T>::node (T data) {
_data = data;
}
While the compiler finds no ...
Consider the following code
template<unsigned int N> void foo(std::bitset<N> bs)
{ /* whatever */ }
int main()
{
bitset<8> bar;
foo(bar);
return 0;
}
g++ complains about this on 64 bit because the <8> gets interpreted as an unsigned long int, which doesn't exactly match the template. If I change the template to say unsign...