CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Foam::DynamicList<Type>.append( new Type );

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By deepsterblue

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   August 3, 2020, 10:15
Default Foam::DynamicList<Type>.append( new Type );
  #1
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 350
Rep Power: 10
Gerry Kan is on a distinguished road
Howdy Foamers:

I have a C++ question. I think I know the answer empirically, but I don't know if my conception is correct.

I have created a DynamicList of some data type (let's call it "Type"). Its starts off with zero elements and I would like to append new terms in it. Currently I would have to declare a new instance in a dummy variable of this "Type" and append this into the list:

Code:
Foam::DynamicList<Type> myList(0);
Type dummy;
myList.append ( dummy );
From reading the code, I believe append() member function makes a copy of dummy into myList. So by that argument I should be able to declare the instance directly in the DynamicList without going through an intermediate variable, like this:

Code:
Foam::DynamicList<Type> myList(0);
myList.append ( new Type );
Okay, I know the new operator will give you a pointer to Type, instead of Type itself. Is there something that will achieve this, or through some kind of temp variable that can be used?

Thanks in advance, Gerry.

Last edited by Gerry Kan; August 4, 2020 at 03:20.
Gerry Kan is offline   Reply With Quote

 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2DOF Planning hull resistance study with overset CFD_fan OpenFOAM Running, Solving & CFD 7 July 13, 2021 05:03
[OpenFOAM.org] compile error in dynamicMesh and thermophysicalModels libraries NickG OpenFOAM Installation 3 December 30, 2019 00:21
rhoPimpleFoam hardship petrus OpenFOAM Running, Solving & CFD 0 October 7, 2016 02:41
interFoam/kOmegaSST tank filling with printStackError/Mules simpomann OpenFOAM Running, Solving & CFD 3 February 17, 2014 17:06
[swak4Foam] Air Conditioned room groovyBC Sebaj OpenFOAM Community Contributions 7 October 31, 2012 14:16


All times are GMT -4. The time now is 16:10.