Visual C++ :: Using Template To Append Item Of Type T To Node Of Ptree

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


ADVERTISEMENT

C/C++ :: Node Insertion Into Boost Libraries - PTree Not Working In MSVC

Dec 24, 2014

I'm currently working on a Microsoft (unmanaged) C++ project which utilizes Boost C++ libraries. It's been quite a while since I've done C++ and I have no previous experience using the Boost libraries.

We are using Boost 1.55 and MSVC 2013. We used CMake to generate the Visual Studio solutions and projects based on the original project layout.

We've successfully built and tested on other environments. In the MSVC - Windows environment, we've run into issues using Boost's Property Tree support. Specifically, the issue seem to center around trying to put properties into PTNodes.

Consider the following code snippet:

void XXX:: SomeFunction() {
PTnode ptNode;
ptNode(Mapper::KEY_INPUT, Tracer::SOME_VALUE);
ptNode(Mapper::KEY_OUTPUT)(Tracer::SOME_OTHER_VALUE, Tracer::ADDITIONAL_VALUE);
SetResults(ptNode);

[Code] ....

This work around seems insert the nodes successfully into the tree.

We are able to verify by finding the inserted items in ::SetResult().

Why this might be failing in VisualStudio C++?

Is this an issue of compiler flags?

precompiler definitions?

Linker options??

Memory mode/model??

Are there some basic behaviour differences in MSVC C++ and other C++ environments which we are unaware of?

I've tried to identify all instances of the node insert pattern and use the work around. But, we really need to find out what the issue is (as there could be other manifestations).

View 1 Replies View Related

C++ :: Append Node To A Linked List

Jan 27, 2013

I have a function that append node to a linked list like this:

struct ListNode{
int value;
struct ListNode* next;
};
void appendNode(struct ListNode* head, int num){

[code] ....

when I use it, the head in main() does not change its address and it's still pointing to NULL. Why??

View 5 Replies View Related

C++ :: Declare Template Type Object Inside Template Type Class Definition

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

Visual C++ :: Determine Type In Function Template

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

Visual C++ :: Enable / Disable Menu Item 2 In OnUpdate Handler Of Menu Item 1?

Sep 15, 2014

I have two menu items. When item 1 is disabled, I want item 2 to be disabled as well. In the OnUpdate handler of menu item 1, I have tried to use "t_pMenu = pCmdUI->m_pMenu;", "t_pMenu = pCmdUI->m_pSubMenu;" and "t_pMenu = pCmdUI->m_pParentMenu;" but I always get NULL t_pMenu. How can I achieve this purpose?

Code:
void CDummyView::OnUpdateMenuItem1(CCmdUI* pCmdUI)
{
if(m_bShowMenuItem1) {
pCmdUI->Enable(TRUE);

[Code]....

View 14 Replies View Related

Visual C++ :: How To Append Two Bitmaps

Nov 28, 2013

Is there a way to append two bitmaps, one of them in a top of another one ? I mean arrange them like tile horizontally.

View 1 Replies View Related

C/C++ :: Node Data Return Type?

Apr 7, 2014

In my main I have a do/while loop, which is to iterate around the method calculateImportance while i is not equal to the numNodes.

do
{
int i;
int numNodes = Test.count();
for(i=0; i<=numNodes; i++)

[Code]....

I have been messing around with the data type node, hence why it is there are present, but, that doesn't seem to the answer

This is the function declaration in the header file.

node CalculateImportance();

View 1 Replies View Related

Visual C++ :: Unable To Append Data To CFile Using FILE

Sep 26, 2012

I'm trying to append data to a CFile using FILE* But when execute the application, it always give error saying "No such file or directory". I can actually see the file created but it just keep giving error "No such file or directory".

Is the file being lock or the file just created so it can not be find by fstream(FILE*)? or the file mode is wrong?

Below is the code:

[QUOTE]
void SaveDocument(CString strFile) {
CFile file;
if( !file.Open(strFile, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyNone)) {
CArchive ar(&file, CArchive::store);
// save now.
MyClass.Serialise(ar);

[Code]...

Attached is the printscreen of the FILE* pointer. the pointer is evaluated as bad pointer. Why the FILE* pointer not able point to the file being created?

View 7 Replies View Related

C++ :: Pass Double Pointer Of Object Into A Node Of Self Similar Type?

Nov 30, 2014

The following code compiles and runs fine till it reaches line 16 and gets a sigsev violation which I'm not sure about as to why. I have no problem passing the object of type node** into the constructor of base and storing it into the double pointer node** copy;; but when I call the function void pass(node** temp) it crashes.

#include <iostream>
class base;
class node {
private:
node** data;
public:

[Code] .....

View 3 Replies View Related

C++ :: Getting Type For A Template?

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

C/C++ :: Use Template Type?

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

Visual C++ :: Menu Item Separator

Aug 6, 2014

I'm using this tutorial for making an owner draw menu. [URL] ...

When I go into the .rc file and remove all of the MENUITEM SEPARATORs all the menu options are squished to the left of the menu as in the screenshot. As long as there is just one MENU SEPARATOR anywhere the menu is fine. If I could make the application without MENU SEPARATORs that would be awesome.

View 7 Replies View Related

C/C++ :: Get Return Type Of Function In Template Parameter

Jul 27, 2012

Is this really the preferred way to get the return type, for use in a derived class, of a function defined in the template parameter?

template<class PARAMETER> class C {
         protected:
            typedef typeof (reinterpret_cast<PARAMETER*>(0))->function() returntype;
      };  

This works just fine for me, but seems inelegant.

View 12 Replies View Related

C++ :: Detect Whether Or Not A Template Type Has A Protected Destructor?

Mar 28, 2014

Is there a way to detect whether or not a template type has a protected destructor?

I see there is std::is_destructible in C++11, but I can't tell if this will return true or false for the protected case. Also, I'm interested in finding a solution for C++03 as well.

View 1 Replies View Related

C++ :: How To Read Tag Name Of Boost Ptree

Mar 23, 2014

[URL] ....

I wonder how tag reading can be achieved? If say I have a file like

<name>
<firstname>John</firstname>
<surname>Robinson</surname>
</name>

I'd like to read "firstname" or "surname" instead of John or Robinson ....

View 4 Replies View Related

Visual C++ :: Point Of ListView - What Row (item) And Column Is

Mar 27, 2013

If we work with a ListView,and want implement some functions like OnLBDblClick(), we only have a CPoint, but not the column and row that this point suppose. How can i Know that, is there another type of functions that gave us the row and column?

View 2 Replies View Related

C++ :: Getting Type Alias From Template Class Without Specifying Arguments And Instantiating It

Feb 4, 2015

For example I want to get the type of std::vector<>::size_type without specifying a template argument.

Here's what I want to do:

std::vector<>::size_type x{5};

Is there any way this can be done?

View 4 Replies View Related

C++ ::  Function Return Type Template Parameters Can't Be Deduced

Dec 9, 2013

I have this code:

#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;

[Code]...

and it does not compile.

The error is:

test.cpp: In function ‘int main()’:
test.cpp:20:30: error: no matching function for call to ‘func1(std::vector<int>&)’
test.cpp:20:30: note: candidate is:
test.cpp:8:45: note: template<class T, class U> std::map<T, T> func1(U)
test.cpp:8:45: note: template argument deduction/substitution failed:
test.cpp:20:30: note: couldn't deduce template parameter ‘T’

View 3 Replies View Related

C++ :: Template Method Based On The Type Passed Should Return A Value

Mar 8, 2014

I have a class where a method based on the type passed I should return a value.

prototype declared in the header file:

template <typename T>int getNum() const;

Code of the cpp file:

template <typename T> int class::getNum() const{
int c = 0;
for(int i=0;i<v.size();i++)
if(typeid(*(Pro*)v.at(i)) == typeid(T)) c++;
return c;
}

To invoke the method as I do:

ostream & operator << (ostream & os, Pro & obj) {
return os << obj.getNum();
}

View 4 Replies View Related

C++ :: Template Class Type - Unresolved Link Errors

Jun 25, 2013

I'm getting unresolved link errors when I attempt to compile.

dNode.h

#ifndef DNODE_H
#define DNODE_H
template <class T>
class dNode {

[Code] ....

ERROR:
Error1error LNK2019: unresolved external symbol "public: __thiscall dStack<double>::dStack<double>(void)" (??0?$dStack@N@@QAE@XZ) referenced in function "void __cdecl stack_test(void)" (?stack_test@@YAXXZ)main.objprog09
Error2error LNK2019: unresolved external symbol "public: virtual __thiscall dStack<double>::~dStack<double>(void)" .......

View 3 Replies View Related

C++ :: Change Behaviour Of Template Class Depending On Type?

Jul 8, 2012

is there a way to have a template class respond to missing stuff in a template type ?

Code:
template <typename Type>
class MyClass
{
public:
enum { ID = Type::ID }; // revert to 1 if Type::ID doesn't exist.
};

If the Type passed to the template has an ID member (required to be an enum or a static const int), use it, if it is missing revert to a default value.

I can use this as a simplified way of configuring how MyClass works, without requiring Type to explicitely needing to define what it doesn't care about.

It needs to be resolved at compiletime, as it determines the number of elements in member array variables.

View 10 Replies View Related

Visual C++ :: Get The Path For A Selected Item In A List Control?

Jan 29, 2013

How do I get the path for a selected item in a list control?

View 5 Replies View Related

Visual C++ :: Change Item Height In CListBox / CListCtrl

Jul 1, 2014

I need a ownerdraw CListBox where I can change the item height during working with the list. The msdn says that I can specify the height in OnMeasureItem when the listbox will be created (ownerdrawfixed) or when an item will be inserted (ownerdrawvariable).

How to change the height e.g. when I click a button?

I made also some tests with CListCtrl. There I can change the height. But there is only one height for all items. How to set individual heights for the items?

View 14 Replies View Related

Visual C++ :: Menu Item To Explore Current Path

Feb 21, 2015

I quite often use an ide written in assembler: RadAsm3[URL] .....

It has a menu item to explore current path. I have used other ide's that have a similar feature but:

The one in RadAsm3 will activate a current Explorer window if the current path is the same as the one requested.
All others open a new Explorer window.

I would like to implement the RadAsm3 approach using Visual Studio 2013 Community c++ as my host compiler for testing.

I tried to get the title of current windows but it appears ShellExecute "explore" does not produce a conventional window???

View 1 Replies View Related

C++ :: Serializing Binary Number With Boost Ptree

Jan 2, 2014

Code:

std::vector<char> normals;
//stored->AddDataObject(TID_D3DRMMeshNormals, ("normals"), 0, normals.size(), &normals[0], &sNormals);
ptree& sNormals = stored.add("normals", &normals[0]);

In the first line, DirectX provides this function to store the normals information in ASCII form. Now in the next line, where I altered the original source code, is storing the binary representation of the same normals vector, what I want to accomplish is to store the normal vector as ASCII ....

Code:
<normals>
<x>0.5</x>
<y>0.5</y>
<z>0.5</z>
</normals>

How can I achieve that with boost?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved