Visual C++ :: Lib Using OLE DB Template
Mar 19, 2013
My question contains two projects that are under the same solution.
Project_1: I have created a dll where I use inside the project, OLE Db Template. In the project, I use this code.
class MyClass {
public:
LONG _value1;
SHORT_value2;
BEGIN_COLUMN_MAP(Accessor)
[Code] .....
Project_2: Is a project testing the Project_1.
- I want to call one of the exported functions.
- In Linker/Addional Dependencies, I have added the .lib
- In Linker/Additional Libray Directories, I have added the directory where is the lib.
- In C/C++/General/Additional Include Directories, I have added the directory on project 1. I did that because I want to #include a header in Project_1. But, when I do that, I get:
Error1error C3646: 'COLUMN_ENTRY' : unknown override specifier
Error2error C2059: syntax error : 'constant'
Error3error C3646: 'COLUMN_ENTRY' : unknown override specifier
I have done it several time with other projects, but the first time with OLE DB Template. atl90.dll is registered.
View 1 Replies
ADVERTISEMENT
Apr 2, 2015
Is there an "easy" way to define a template with a template parameter that could resolve to "nothing".
Code:
template <typename T1, typename T2, typename T3>
struct one_to_three {
public:
T1 t1;
T2 t2;
T3 t3;
};
Now I want to be able to instantiate that in such a way that T3 and T2 (if T3 also) resolve to "nothing".
Don't point me at tuple<>, this has to be a single structure. No dummy's, nothing effectively means nothing.
so on Win32
Code:
one_to_three <int, int, int> x;
sizeof(x) == 12;
one_to_three <int, nothing, nothing> y; // whatever 'nothing' needs to be.
sizeof(y) == 4;
T1 will never be 'nothing'
T2 will only be 'nothing' if T3 also is 'nothing' (if it works with T3 not being nothing, that's fine, but it won't get used that way).
Portability is a non-issue, this only needs to work in VS (2010 and higher). The 'real' solution will need up to T10, I have a solution working with SFINAE, but it takes very very long to compile and it's getting very unwieldy if you would need to add T11.
I know it's not an ideal type approach, but it is what it is, this is a necessity due to linking with a legacy API which we don't have control over.
View 9 Replies
View Related
Oct 18, 2013
Consider the following code:
Code:
template<class TYPE>
void MultiplyByTwo(TYPE data) {
cout <<"Double = " << data * 2 << endl;
}
If I declared that code in a header file I'd be able to call it with an int, float, double or whatever. But where does the actual code get instantiated? Is it effectively inlined?
What I'm wondering is if there'd ever be any scenario for putting such code in a DLL - e.g.
Code:
#ifdef BUILDING_MY_DLL
#define MY_DLL_API __declspec(dllexport)
#else
#define MY_DLL_API __declspec(dllimport)
#endif
template<class TYPE>
MY_DLL_API void MultiplyByTwo(TYPE data) {
cout <<"Double = " << data * 2 << endl;
}
I just tried it and was slightly surprised to find it wouldn't compile. It compiles fine when actually building the DLL but when I try to build something else which uses that DLL I get compiler error C2491 (definition of dllimport function not allowed).
I guess that kinda makes sense if template functions are effectively inlined... or is there some other explanation....
View 14 Replies
View Related
Jul 28, 2013
I want to detect the type in a function template, like this:
template <class myType> myType Function (myType a, myType b) {
//Detect the myType
If (myType is int)
[Code] ......
Is that possible?
View 6 Replies
View Related
Jun 9, 2013
I'm doing a homework aasignment on templates, and i have to build a list. The problem starts when i am trying to add elements to the list. For instance if i chose to add 5 different elements (1,2,3,4,5) the output will be (5,5,5,5,5).
Code:
void add_back(T t){
Node* tmp = new Node;
tmp -> m_data = &t;
if(m_head == NULL) {
[Code] ....
View 4 Replies
View Related
Jun 13, 2014
I stumbled upon an unexpected difference between GCC and VisualStudio: Different overloaded functions are called in the following example:
// -------- can assume this is located in 'tool.h' file --------------
// Fwd declaration support foo( const int& ) gets called as expected by both compilers
// void foo( const int& n );
template< typename T >
void foo( const T& n ) {
[Code] ....
What happens: I expected that by calling bar(1) compiler will notice both versions of foo() and call the best match, in this case foo(const int&). That is not the case.
Note that overloaded foo(const int&) is below bar(). It seems that at that point GCC does not see overloaded version, and happily calls template version. Visual studio on the other hand has no problem finding them both.
If I introduce a forward declaration of foo( const int& ) before bar(), both compilers call that version correctly. Unfortunately, that is not a solution for my problem here.
Template version is part of a library while overloaded is part of the user code. Both would be located in different (header) files and I would not like to impose #include order to the users or to be dependant on it.
View 2 Replies
View Related
Jan 5, 2014
What my purpose here is to use a template to append an item of type T to a node of a ptree (boost)
Code:
template<typename T>
ptree& stick(ptree& tree, char *location, T const & t) {
return tree.add(location, t);
}
Here I can't compile
Code:
struct hdr {
WORD weights_per_vertex;
WORD weights_per_face;
WORD num_bones;
[Code] ....
Doesn't the type of T includes the type struct hdr?
View 3 Replies
View Related
Dec 5, 2013
I'm trying to implement a simple template array class, but when i came into the operator< i actually have to use a template :
my code is something like :
template<typename _Type, std::size_t _Size>
class array {
public :
[Code] ......
but i am having an error of shadows template param 'class _Type' is it w/ the name conflict between the array template parameter and the function template parameter ?
View 6 Replies
View Related
Nov 6, 2013
Error1error C2955: 'DoubleLinkedListInterface' : use of class template requires template argument listdoublelinkedlist.h10
Error2error C2244: 'DoubleLinkedList<T>::DoubleLinkedList' : unable to match function definition to an existing declaration doublelinkedlist.cpp7
Error3 .cpperror C2244: 'DoubleLinkedList<T>::~DoubleLinkedList' : unable to match function definition to an existing declaration 12
.h
#pragma once
#include "DoubleLinkedListInterface.h"
#include "Node.h"
#include <iostream>
[Code]....
View 4 Replies
View Related
May 27, 2013
I have a generic template class with another template in one of its types. Now I want to specialize one of its methods for a particular (template) class, which leads to a compile error, however.
Here is the example:
#include <stdio.h>
template<typename Type>
class Obj1 {
public:
void ID() { printf("Object 1, size = %zu
[Code] .....
GCC ends with:
:35:27: error: type/value mismatch at argument 2 in template parameter list for ‘template<class Type, template<class> class O> class Foo’
:35:27: error: expected a class template, got ‘Obj2<Type>’
What is wrong with the specialization? Can it even be achieved and how (if so)?
View 1 Replies
View Related
Nov 2, 2014
how I want the code to look. Only problem is it doesn't work (Line 11). I have some experience with templates but I'm not a pro.
Basically I want the "Channels<3>" to be a type that I can use to specify a Cable with similar to vector<float/int> it would be Cable<Channels<2 or 3>>.
What have I messed up with the syntax?
#include <iostream>
#include <vector>
using namespace std;
[Code].....
View 4 Replies
View Related
Mar 14, 2014
I have a function:
template<class Iterator, class T>
void a(Iterator, Iterator, const T&);
and I want to be able to simplify calls to 'a' with calls like
a(someIteratableContainer);
instead of having to call:
a(someIteratableContainer.begin(), someIteratableContainer.end(), valueOfTheContainersElementType);
I also want to be able to generalize the function to handle any of the standard iteratable contains: array, vector, deque, whatever.
I was under the impression I could write:
template<template<class T> class U> a(U<T>& container) {
a(container.begin(), container.end(), g(T()));
}
where 'g()' returns an object of the element type. However, the compiler is claiming, no matter how I write a call to the overload, the original template is selected and/or the overload is invalid, depending on the various ways I attempt to write said overload.
View 7 Replies
View Related
Nov 17, 2013
[URL]
#include <iostream>
struct Outer {
template<typename T>
void go() {
std::cout << Test<T>::f() << std::endl;
[Code] .....
I have tried several variants on this code to no avail. Outer is in a header, along with the extern template statements, and the specializations after main are in their own cpp file. Main is in a different cpp file.
What do have to do to make this work? I cannot bring the definitions of f() into the header, and they will be different for different template parameters. Ideally, I want Test to remain a private member of Outer, though this can change if it's the only option.
View 1 Replies
View Related
Dec 11, 2014
I have been trying to get a hang on templates. I have the two following functions that that could be consolidated in a single template function:
void Attractor::updateFamilies(FamiliesController *_tmp, int _counter){
center.x = ofGetWidth()/2;
center.y = ofGetHeight()/3;
attractorCounter = _counter;
if(attractorCounter == 1){
[Code] .....
NotesController and FamiliesController have the same parent. The thing that I'm trying to grasp with templates is that is could something like:
template<class TYPE>
void Attractor::updateData(TYPE* *_tmp, int _counter){
center.x = ofGetWidth()/2;
center.y = ofGetHeight()/3;
attractorCounter = _counter;
[Code] ....
And then have another template function declaration for all the attractor functions where I pass the same template value as in the first one.
As you can see, I'm calling another functions inside called attractors(_tmp). I know that one way around it could be to get rid of that function and just do all the logic inside of each if statement. Is there any way to pass the same template function parameter within a template function parameter?
View 2 Replies
View Related
Feb 9, 2015
I have a class like this
PHP Code:
template<class X>
class A {
X m_x;
public:
X* foo();
X* bar();
//others are not related to X
};
I would like to get rid of
PHP Code: template<class X>
For class level but still use it for members. Like this
PHP Code:
class A {
X m_x;
public:
template<class X>
X* foo();
template<class X>
X* bar();
//others are not related to X
};
However, I am still stuck at
PHP Code: X m_x;
View 6 Replies
View Related
Oct 12, 2013
Let me put it into the code snippet:
/**
This class build the singleton design pattern.
Here you have full control over construction and deconstruction of the object.
*/
template<class T>
class Singleton
[Code]....
I am getting error at the assertion points when i call to the class as follows:
osgOpenCL::Context *cxt = osgOpenCL::Singleton<osgOpenCL::Context>::getPtr();
I tried commenting assertion statements and then the debugger just exits at the point where getPtr() is called.
View 7 Replies
View Related
Aug 29, 2014
Given:
#include <string>
template <class T>
class basic_container{
[Code] .....
is this possible:
#include "../basic_container/basic_container.hpp"
template <class T>
class container_vector{
[Code] .....
If not, what do I need to do to achieve my goal?
View 1 Replies
View Related
Dec 11, 2013
I'm getting tired of writing Code: template <typename T> everywhere.
Is the only solution to encapsulate all my desired functions in a templated class?
View 7 Replies
View Related
Dec 12, 2013
unknownType func( void );
std::vector< /* type of unknownType */ > objects
The source of my question is trying to make a templated button:
template <typename T>
class Button
{
T m_func;
[Code]....
View 2 Replies
View Related
Sep 28, 2013
i have 1 class:
from here: [URL]
template <typename Container, typename ValueType, void (Container::*setptr)(ValueType t),ValueType (Container::*getptr)(), int nPropType=3>
class property {
[code]....
(but i did the version 2;))
my question is: can i put these:
void setContainer(Container* cObject) {
m_cObject = cObject;
}
in header template?
i did these:
template <typename Container,Container* cObject, typename ValueType, void (Container::*setptr)(ValueType t),ValueType (Container::*getptr)(), int nPropType=3>
class property {
[Code] .....
how use it:
property <person2,this,string,&person2::setname,&person2::getname> Name;
(person2 is the class name)
errors messages:
"C:UsersJoaquimDocumentsCodeBlocks esteventsmain.cpp|31|error: invalid use of 'this' at top level|"
"C:UsersJoaquimDocumentsCodeBlocks esteventsmain.cpp|31|error: template argument 2 is invalid|"
how can i use the 'this' in template header?
View 1 Replies
View Related
Dec 4, 2014
I would like to use my own template type. I have class Fraction that saves fractions, and class Sample(the template class) that arrange fractions in order.
template <typename T> class Sample{
// code
};
class Fraction{
// code
}
main(){
Sample <Fraciton> s; //
return 0
}
but
Sample <Fraciton> s;
does not work. Is there anyway to make this work.
View 4 Replies
View Related
Feb 4, 2014
std::cout << "Hello C++ programmers!" << std::endl;
I am trying to create a LinkedList (and then, an ADT stack; // yes, I cannot use the STL stack because the teacher won't let me), and I am getting some weird error when I create a ListNode and declare LinkedList (which has the ListNodes!) a friend of it.
Here is my header-file code for both classes:
ListNode.h
#ifndef LISTNODE_H
#define LISTNODE_H
#include "LinkedList.h"
[Code]...
The errors I am getting are:
error: 'LinkedList' is not a class template
I have tried forward-declaring LinkedList in the ListNode.h file, but I get this error:
error: 'ListNode' does not name a type
Are there any other possible solutions to this problem; // without having to resort to crazy stuff like having a .h file #include a .cpp file, or even declaring and defining ALL OF MY CODE in the .h files???
View 6 Replies
View Related
Mar 22, 2013
I have this macro, that expands to some methods of my class:
Code:
#define POPULAR_COMBO_FILTRO_COM_BASE(classeTabela)
void VisualizadorLogsFrame::PopularComboFiltroCom ## classeTabela (bool limparTexto) {
long from, to;
m_cbxDetalhe->GetSelection(&from, &to);
[Code]...
but I get a compile error on this line:
Code:
for (list< CLASSE_TABELA *>::iterator linha = lista->begin(); linha != lista->end(); linha++) {
what am I doing wrong ? the error is:
VisualizadorLogsMain.h:174: error: expected ';' before 'linha'
VisualizadorLogsMain.h:174: error: 'linha' was not declared in this scope
View 4 Replies
View Related
Jan 24, 2012
I'm trying to make a template class which holds a template list I made. The list consists of template nodes (another template class I made).
My problem is that in some places (not everywhere) the compiler says that I'm trying to access private members of the node's class.
For example, if I define my node like this:
template<class T>
class CoefNode {
private:
T coef;
[Code]....
View 5 Replies
View Related
Jan 11, 2015
How do I make a Template that has 2 stacks ?
Code:
template <class T>
class A {
};
template <class T>
class B {
};
is this code correct ?
View 1 Replies
View Related
Mar 3, 2013
I have this class templates And This UML.I have to write this function +operator=(source: Array<ElemType, SIZE>): Array<ElemType, SIZE> but I do not know how to start the declaration / or start the function. I have to return a template but I do not know how to do it,
UML
Array<ElemType, SIZE>
-elements: ElemType[SIZE]
+Array()
+Array(source: Array<ElemType, SIZE>)
+operator=(source: Array<ElemType, SIZE>): Array<ElemType, SIZE>
+operator==(other: Array<ElemType, SIZE>): Boolean
+operator!=(other: Array<ElemType, SIZE>): Boolean
<<L-value>>+operator[](index: Integer): ElemType
<<R-value>>+operator[](index: Integer): ElemType
[code]....
View 4 Replies
View Related