null

C++ standard: dereferencing NULL pointer to get a reference? [duplicate]

怎甘沉沦 提交于 2020-01-04 05:21:37
问题 This question already has answers here : Is null reference possible? (4 answers) Closed 6 months ago . I'm wondering about what the C++ standard says about code like this: int* ptr = NULL; int& ref = *ptr; int* ptr2 = &ref; In practice the result is that ptr2 is NULL but I'm wondering, is this just an implementation detail or is this well defined in the standard? Under different circumstances a dereferencing of a NULL pointer should result in a crash but here I'm dereferencing it to get a

C++: Compare return value of C function to NULL or nullptr?

牧云@^-^@ 提交于 2020-01-04 04:42:09
问题 I'm coding in C++, and using a C function that returns NULL in case of a failure. What would be the correct think to do, compare its return value to NULL or nullptr? if ((CreateEventEx(myEventHandleHere) == NULL) { ... } or if ((CreateEventEx(myEventHandleHere) == nullptr) { ... } 回答1: The draft C++ standard in appendix C.4 C Standard library which is non-normative says: The macro NULL, defined in any of <clocale>, <cstddef>, <cstdio>, <cstdlib>, <cstring>, <ctime>, or <cwchar>, is an

Grails datasource becoming null in Service

眉间皱痕 提交于 2020-01-04 04:39:22
问题 I am using Grails 2.2.1, and I have a custom dataSource injected into the service so that I can execute some SQL queries. Upon first execution, there is a dataSource, but on each subsequent call, the reference to the dataSource has become null. class ReportService { def dataSource_myds Object[] reportRecords(int a) { String query = "SELECT ..." Object[] resultSet; Sql sql = new Sql(dataSource_myds) // ^ Here the NullPointerException is thrown // But it always works at the first execution sql

PrimeFaces DataTable selection goes null on dialog.show()

混江龙づ霸主 提交于 2020-01-04 04:02:50
问题 I've got a BIG problem using Datatable and Dialog together. I need to click on a datatable's row and showing a dialog which loads data from datatable's selected item. Selection goes fine, but the selected element is set to null as soon as the dialog is shown :/ Here's some code : <h:form id="form"> <pou:dataTable widgetVar="conv" id="mex" var="conv" value="#{messagesBean.listaConversazioni}" paginator="true" rowKey="#{conv}" paginatorPosition="bottom" selection="#{messagesBean.destinatario}"

Swift Get Video Frame use AVFoundation

巧了我就是萌 提交于 2020-01-04 02:41:04
问题 This is my code: I want get my video and get the frame data to an SceneKit SCNSphere. //NSString videoPath=NSBundle.mainBundle().l var videoURL=NSBundle.mainBundle().URLForResource("video", withExtension: "mp4") var assetOptions = [AVURLAssetPreferPreciseDurationAndTimingKey : 1] videoAsset=AVURLAsset(URL: videoURL, options: assetOptions) var error:NSError? var videoAssetReader=AVAssetReader(asset: videoAsset, error: &error) //var duration = CMTimeGetSeconds(videoAsset.duration) //println

Typescript 2.0 typeof null variable is undefined

僤鯓⒐⒋嵵緔 提交于 2020-01-03 22:28:56
问题 I am newly learning Typescript and I run through a strange behavior, I was trying to declare two variables one null and the other undefined as it is a new feature introduced in Typescript 2.0. let myNullVar :null; let myNullVar2 : undefined; console.log(typeof myNullVar); console.log(typeof myNullVar2); I was expecting to see this output: null undefined But it was: undefined undefined More, when I do this: if(typeof myNullVar === 'null'){ console.log('null'); } else if (typeof myNullVar ===

Querydsl null-safe concatenation

若如初见. 提交于 2020-01-03 18:53:32
问题 Suppose you have the following data in table corresponding to the class Person , what is the correct way to search null-safely for the concatenation of fields name1 and name2 ? @Entity public class Person { Long id; String name1; String name2; // Getters and setters omitted for brevity } id | name1 | name2 ------------------------ 1 | Foo | null 2 | null | Bar 3 | Foo | Bar By default the concatentation of two columns results in null if either is null. public List<String> nameConcatenations()

Ruby use case for nil, equivalent to Python None or JavaScript undefined

廉价感情. 提交于 2020-01-03 15:28:12
问题 How does Ruby's nil manifest in code? For example, in Python you might use None for a default argument when it refers to another argument, but in Ruby you can refer to other arguments in the arg list (see this question). In JS, undefined pops up even more because you can't specify default arguments at all. Can you give an example of how RubyNone pops up and how it's dealt with? I'm not looking for just an example using nil . Preferably it would be a real code snippet which had to use nil for

ng-repeat filter null value not displaying

ぃ、小莉子 提交于 2020-01-03 13:57:50
问题 Why won't angular display values that are null when I apply: ng-repeat="p in foo | filter: filter2" where filter2 is $scope.filter2 = function(p){ if (p.state === null){ return p.state; } else{ return; } }; here's a plnkr with what I'm saying: http://plnkr.co/edit/cj3v1fuBu6sHVI7A4qlq?p=preview The filter works when it's anything but a null but I'm trying to only the null ones to display. I could try changing all the null values to a default value string other than a null? Is there anywhere

Concatenation of a null String object and a string literal

久未见 提交于 2020-01-03 12:28:10
问题 This is a follow-up question to some previous questions about String initialization in Java. After some small tests in Java, I'm facing the following question: Why can I execute this statement String concatenated = str2 + " a_literal_string"; when str2 a String object initialized to null ( String str2 = null; ) but I cannot call the method toString() on str2 ? Then how does Java do the concatenation of a null String object and a string literal ? By the way, I tried also to concatenate an