new-operator

Private operator delete triggers compile-time error with GCC and Clang but not with MSVC

北战南征 提交于 2019-12-04 04:08:27
问题 Motivated by this not very well asked duplicate, I believe the problem deserves a new standalone clearly titled question. The following code triggers a compilation error with GCC 8.1.0 and Clang 6.0.0, but not with MSVC 19.00: class X { public: X() /* noexcept */ { } private: static void operator delete(void*) { } }; int main() { X* x = new X{}; } From expr.new: If any part of the object initialization described above terminates by throwing an exception and a suitable deallocation function

What effect does the “new” keyword have in C# and why is it only a warning when not employed?

↘锁芯ラ 提交于 2019-12-04 04:02:59
Consider the following code: public abstract class Test1 { public object Data { get; set; } } public abstract class Test2<T> : Test1 { public T Data { get; set; } } This will generate the following warning: 'Test2.Data' hides inherited member 'Test1.Data'. Use the new keyword if hiding was intended. Why is this only a warning and what effect will adding the "new" keyword have? According to my testing I cannot find any difference once the "new" keyword is added. Don't get me wrong, I'm all for being explicit, but I was curious as to the benefit of adding "new". My only thoughts on what it might

Reallocating memory via “new” in C++

北城以北 提交于 2019-12-04 02:37:25
Quick question regarding memory management in C++ If I do the following operation: pointer = new char [strlen(someinput_input)+1]; And then perform it again, with perhaps a different result being returned from strlen(someinput_input) . Does this result in memory being left allocated from the previous " new " statement? As in, is each new statement receiving another block of HEAP memory from the OS, or is it simply reallocating? Assuming I do a final delete pointer[]; will that deallocate any and all memory that I ever allocated via new to that pointer? Every call to new must be matched with a

difference between Function and new Function

北城余情 提交于 2019-12-04 01:19:04
问题 I sometimes see people doing this Function('alert("hi")') and sometimes they do new Function('alert("hi")') Is there a difference between the two? 回答1: The spec (page 127) says they're identical. 15.3.1.1 Function (p1, p2, … , pn, body) When the Function function is called with some arguments p1, p2, … , pn, body (where n might be 0, that is, there are no “p” arguments, and where body might also not be provided), the following steps are taken: Create and return a new Function object as if the

Hiding symbols in a shared library on Mac OS X

半腔热情 提交于 2019-12-04 00:48:19
问题 We've been building a large open source software on a variety of platforms (Linux, Windows, Mac OS X, 32-bit and 64-bit) for several years without troubles. Lately however, the Mac OS X build (64-bit) stopped working correctly and started to crash randomly. It more or less coincided with an update of Mac OS X on our build machine from 10.7 to 10.8.2 (but the compiler toolchain didn't change, it's still llvm-gcc 4.2.1). Our application is made of a couple of dynamic (shared) libraries and many

IE won't load PDF in a window created with window.open

随声附和 提交于 2019-12-04 00:09:19
Here's the problem, which only occurs in Internet Explorer (IE) . I have a page that has links to several different types of files. Links from these files execute a Javascript function that opens a new window and loads the specific file. This works great, unless the file I need to open in the new window is a PDF in which case the window is blank, even though the URL is in the address field. Refreshing that window using F5 doesn't help. However, if I put the cursor in the address field and press <enter> the PDF loads right up. This problem only occurs in IE. I have seen it in IE 7 and 8 and am

Reversing CRC32

和自甴很熟 提交于 2019-12-03 23:12:45
I found a code to reverse CRC32 but I don't know how it works, because im not that good in programming, I just started. I just want to compare 2 files, the old and the new one, then in the new fix the CRC32 adding 4 bytes at the end of the file, so the 2 files will have the same CRC32. Here is the code, is in C#: public class Crc32 { public const uint poly = 0xedb88320; public const uint startxor = 0xffffffff; static uint[] table = null; static uint[] revtable = null; public void FixChecksum(byte[] bytes, int length, int fixpos, uint wantcrc) { if (fixpos + 4 > length) return; uint crc =

iPhone AddressBook - how to create a new record with app from my App

我的未来我决定 提交于 2019-12-03 22:33:18
I'm trying to create a new record of Person thru my App. I have the name, email and phone nr. How can i pass them to the modal view of newPerson? I'm following Apple's docs, but i'm stuck. I'm using a ABNewPersonViewController. Is that correct? How do I fill the fields in the modal view? Thanks, RL Jason Coco If you want to display something in the ABNewPersonViewController, you have to create and set up an ABRecordRef for the properties you want to pre-fill and then set the displayedPerson property on ABNewPersonViewController. So a simple example may be: - (void)createNewPerson { // Create

How to create a new source code branch using TFS API?

强颜欢笑 提交于 2019-12-03 21:59:09
问题 I am trying to create a new branch using the API, and have used both PendBranch() and CreateBranch() . The problem with CreateBranch() is it commits immediately and I want to be able to add comments as the branch is checked in. So, I what I did is shown below. Basically I get all the information like server item and local item to be mapped as well as source and target of the branch from my windows application. Somehow, when I see Source Control Explorer it still says "Not mapped" even though

How do I get a new object using Ninject as in this example

旧巷老猫 提交于 2019-12-03 21:44:33
I am in need of adding an item of type IVehicle which is injected at runtime from constructor to a for loop. IVehicle vehicle; for (int i=0;i<=someValue;i++) { list.insert(i,vehicle); //some processing to assign values } now because Ivehicle is already injected by this time, my list has same value despite the value on view different and coming through the controller. How can I new up this object everytime EDIT The best way to new up this object everytime I found was to request new from the kernel that was injecting it. I am using Ninject as said earlier. All I did was use a create a variable