I have have the following code using templates and array dimension as template non-type parameter
template<int n> double f(double c[n]);
...
double c[5];
f<5>(c); // compiles
f(c); // does not compile
should not the compiler to be able to instantiate the second f without explicit template parameter? I am using g++4.1
thanks
...
I want to be able to define
template <class TX>
void f(const TX &x){ ... }
template <class TY>
void f(const TY &x){ ... }
where TX must be derived from BaseX and TY must be derived from BaseY (how do I specify this kind of thing?), and I want to be able to call it as
f(DerivedX<T>())
It is most important that I can avoid specifying...
Hi,
I am looking for a special template class, hopefully either a QT template or a self-contained open source library. This template class is intended to act as a container for a set of objects. Each object in the set has an integer-valued weight function but the weight function itself is arbitrary. It could range uniformly from 10 to ...
I have a moderately simple assignment, to create a PHP/PDO site with login functionality and article retrieve/save/edit/search. No tags, nothing else.
Is this overkill to use some framework for this?
It it a good decision to use custom code + perhaps template system like Smarty for a simple site that will not grow too much?
Is there a ...
Hi, I've been trying to do this simple stuff and Visual studio 2008 does not seems to like it.
template <class CharType>
class SomeClass
{
public:
template <class T1, class T2>
static bool SomeOperator(const typename T1::const_iterator& p_Begin1,
const typename T1::const_iterator& p_End1,
...
I already asked two questions related to what I'm trying to do (one resolved, one of which I will close soon). I know that C++ template instantiation does not allow any implicit conversions (see for example this comment), but I would like to simulate it.
Suppose I have the following skeleton code:
template <class T>
struct Base_A{
...
The Setup
I want to consume a web service in Visual Studio. I added a service reference, pointing it at a WSDL document. I get a bunch of generated code that works like a champ.
The Problem
In the Service Reference dialog, I selected "Internal" as the "Access level for generated classes." It appears as though that puts the "interna...
I have a Cakephp project
the controller has several different methods.
function Index()
function IndexAuthor()
And I want to use the same 'view' (or template, Index.ctp) for both of the methods of the control.
...
Is possibile begin edit of a specific cell from code behind with DataGrid control (WPF Toolkit)?
I have to enable the celledittemplate of first cell of selected row after a button action...how can I do?
...
Silverlight's Navigation Application template seems promising, however, I can't seem to find any tutorials (particularly video tutorials). Whatever I did find was from the beta and is inconsistent with the released version.
Has anyone seen any non-beta tutorials (particularly video)?
...
I would like to indicate the currently chosen page in a shared menu component of a web page in a Struts Tiles project.
I can think of some possible solutions
check current URL
call some Javascript to indicate
possibly hooked into the tiles or struts config files and read.
I'm sure this problem has been faced many times before. What...
I've done a lot of server-side HTML programming and used a number of different template languages for producing (X)HTML. This part is very clear to me.
But what I'm wondering a bit about is how do people use this in client-side JavaScript programs? I mean, obviously there can be template languages written for JavaScript that work inside...
Hi everybody,
Bumped into another templates problem:
The problem: I want to partially specialize a container-class (foo) for the case that the objects are pointers, and i want to specialize only the delete-method. Should look like this:
The lib code
template <typename T>
class foo
{
public:
void addSome (T o) { printf ("adding...
Hello everybody.
Lets say you have simple template function (not class member for the sake of simplicity) with type specific specialization in the same .h file...
template <class TYPE>
void some_function(TYPE& val)
{
// some generic implementation
}
template <>
inline void some_function<int>(int& val)
{
// some int specific ...
Hi,
This is similar to a recent question.
I will be maintaining sorted a list of values. I will be inserting items of arbitrary value into the list. Each time I insert a value, I would like to determine its ordinal position in the list (is it 1st, 2nd, 1000th). What is the most efficient data structure and algorithm for accomplishing...
someone already asked this question, but the thread ended up with the original question not getting answered.
suppose you have this:
template<size_t i, class f_type>
void call_with_i(f_type f);
functor_type is either:
a) a struct with a method that has the following signature:
template<size_t i> operator()() const;
or, b) a fun...
Here I have functor of the follow kind:
template<class T, class Foo, T Foo::*p>
struct X {
void operator()(Foo & f) {
(f.*p) = 12 * (f.*p); // simple example. could be more complex `operator()`
}
};
And sample struct:
struct FF
{
int m;
int r;
};
I want to use the functor X, but I don't want to explicitly spec...
One could break the question into two: how to read and to write templated code.
It is very easy to say, "it you want an array of doubles, write std::vector<double>", but it won't teach them how the templates work.
...
Hello guys, I'm trying to implement this code to have different files to load for german, spanish or english browser languages of choice.
The case is that with my spanish IE I still get the english file.
<?php
if (is_home()) {
if (preg_match('/de-DE/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
include(TEMPLATEPATH . '/german-navbar.p...
Basically, given a template class like this:
template< class Value > class Holder { };
I would like to be able to discover the type Value for a given Holder class. I thought that I would be able to make a simple metafunction that takes a template template argument, like this:
template< template< class Value > class Holder > class Ge...