OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Why not const pointers in array setters


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Bruno Oliveira
Guest





PostPosted: Mon May 29, 2017 12:47 pm    Post subject:
Why not const pointers in array setters
Reply with quote

Hello,



in array setters, for instance in osg::Geometry::setVertexArray, why is the array argument non-const?


How bad is it that I const_cast an array of my into a Geometry?

------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10982

PostPosted: Mon May 29, 2017 6:36 pm    Post subject:
Why not const pointers in array setters
Reply with quote

Hi Bruno,

On 29 May 2017 at 13:42, Bruno Oliveira <> wrote:
Quote:
in array setters, for instance in osg::Geometry::setVertexArray, why is the
array argument non-const?

osg::Geometry takes/shares ownership of the array you pass in so it's
free to delete, modify it, or other parts of the OSG/your application
are free to modify it, so it can't enforce that the array you pass in
is const. If you can't enforce it being const that having a const
input would be misleading.

Quote:
How bad is it that I const_cast an array of my into a Geometry?

It's not bad, unless your application relies on no other part of the
OSG/your application modifying that array so actually intend it to be
fully const. Hopefully it will flag up that fact that the assumptions
you might have been previously making might no longer hold.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Setting vertex attribute array of float Bruno Oliveira General 1 Mon Mar 20, 2017 9:55 am View latest post
No new posts Draw vertex as Circle with color give... Bruno Oliveira General 7 Mon Jan 02, 2017 7:22 pm View latest post
No new posts Vertex Array Object branch Mathieu Submission 11 Fri Aug 05, 2016 7:47 am View latest post
No new posts Why is setTexCoordArray(0,texcoords) ... florian General 11 Thu Jul 07, 2016 9:24 am View latest post
No new posts osgUtil::CullVisitor missing const qu... mp3butcher Submission 3 Sat Jul 02, 2016 1:37 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP