standards

What's the best “file format” for saving complete web pages (images, etc.) in a single archive? [closed]

和自甴很熟 提交于 2019-11-27 05:12:59
问题 I'm working on a project which stores single images and text files in one place, like a time capsule. Now, most every project can be saved as one file, like DOC, PPT, and ODF. But complete web pages can't -- they're saved as a separate HTML file and data folder. I want to save a web page in a single archive, and while there are several solutions, there's no "standard". Which is the best format for HTML archives? Microsoft has MHTML -- basically a file encoded exactly as a MIME HTML email

Base pointer to array of derived objects

旧街凉风 提交于 2019-11-27 05:05:49
Following a question asked here earlier today and multitudes of similary themed questions, I'm here to ask about this problem from stadard's viewpoint. struct Base { int member; }; struct Derived : Base { int another_member; }; int main() { Base* p = new Derived[10]; // (1) p[1].member = 42; // (2) delete[] p; // (3) } According to standard (1) is well-formed, because Dervied* (which is the result of new-expression ) can be implicitly converted to Base* (C++11 draft, §4.10/3): A prvalue of type “pointer to cv D”, where D is a class type, can be converted to a prvalue of type “pointer to cv B”,

Why the sizeof(bool) is not defined to be one, by the Standard itself?

不问归期 提交于 2019-11-27 04:57:28
Size of char , signed char and unsigned char is defined to be 1 byte, by the C++ Standard itself. I'm wondering why it didn't define the sizeof(bool) also? C++03 Standard $5.3.3/1 says, sizeof(char), sizeof(signed char) and sizeof(unsigned char) are 1; the result of sizeof applied to any other fundamental type (3.9.1) is implementation-defined. [Note: in particular,sizeof(bool) and sizeof(wchar_t) are implementation-defined .69) I understand the rationale that sizeof(bool) cannot be less than one byte . But is there any rationale why it should be greater than 1 byte either? I'm not saying that

Are there stackless or heapless implementation of C++?

半世苍凉 提交于 2019-11-27 04:48:42
C++ standard does not mention anything about the stack or the heap, they are implementation specific , which is true. Even though they are not part of the C++ standard, we end up using them anyway, so much that it's like they are part of the language itself and have to be taken into consideration for memory or performance purpose. Hence my question are there implementations of C++ that doesn't use stacks and heaps? Others have already given good answers about the heap, so I'll leave that alone. Some implementations (e.g., on IBM mainframes) don't use a stack as most people would think of it,

Passing NON-POD type to Variadic function is undefined behavior?

。_饼干妹妹 提交于 2019-11-27 04:45:48
问题 In this document, the author said Only a POD-type can be an argument for the ellipsis "..." while std::string is not a POD-type. I'm understanding this as Passing NON-POD type to Variadic function is undefined behavior . Is it right? Though, is he saying C/C++ standard? I tried to find it at n3242 C++ spec. But can not find. I'd like to know I'm understanding rightly and this is a standard. 回答1: It's specified in C++11 5.2.2/7: Passing a potentially-evaluated argument of class type having a

In C++, when can two variables of the same name be visible in the same scope?

纵饮孤独 提交于 2019-11-27 04:38:43
问题 This code illustrates something that I think should be treated as bad practice, and elicit warnings from a compiler about redefining or masking a variable: #include <iostream> int *a; int* f() { int *a = new int; return a; } int main() { std::cout << a << std::endl << f() << std::endl; return 0; } Its output (compiled with g++): 0 0x602010 I've looked at a couple references (Stroustrup and The Complete C++ Reference) and can't find anything about when and why this is allowed. I know that it's

Closest ancestor matching selector using native DOM?

你离开我真会死。 提交于 2019-11-27 04:30:59
问题 Is anybody working on a jQuery.closest() equivalent in the DOM api? Looks like the Selectors Level 2 draft adds matches() equivalent to jQuery.is(), so native closest should be much easier to write. Has adding closest() to Selectors come up? 回答1: Element.closest() its support Implementing such function with Element.matches() seems not optimal in terms of performance, cause apparently matches() will make a call to querySelectorAll() every time you test a parent, while only one call is

Why don't the C or C++ standards explicitly define char as signed or unsigned?

这一生的挚爱 提交于 2019-11-27 04:27:55
int main() { char c = 0xff; bool b = 0xff == c; // Under most C/C++ compilers' default options, b is FALSE!!! } Neither the C or C++ standard specify char as signed or unsigned, it is implementation-defined. Why does the C/C++ standard not explicitly define char as signed or unsigned for avoiding dangerous misuses like the above code? Historical reasons, mostly. Expressions of type char are promoted to int in most contexts (because a lot of CPUs don't have 8-bit arithmetic operations). On some systems, sign extension is the most efficient way to do this, which argues for making plain char

Semantically, which is more correct: a in h2, or h2 in a?

℡╲_俬逩灬. 提交于 2019-11-27 04:27:34
I'm stuck deciding which to use as both seem to work. Should I be placing links <a> inside of <h2> elements? Or the other way around? What is the correct standard? You can only place <h2> elements within <a> elements if you're working with HTML5, which allows any other elements within <a> elements . Previous specifications (or current ones however you want to look at them) never allowed this. The usual way of doing this is to place <a> within <h2> . This works, has always worked, and has been the only valid way to do it before HTML5, for heading links, as the link refers to the text in that

Detecting HTML5 Drag And Drop support in javascript

夙愿已清 提交于 2019-11-27 04:27:28
问题 I'm trying to detect the HTML5 Drag And Drop support in JavaScript. Modernizr seems to not handle this test case. 回答1: You can do this: if('draggable' in document.createElement('span')) { alert("Drag support detected"); } You can see a quick demo test using the above check here. Also, there's a nice feature detection (not browser detection, yay!) list that's fairly well maintained here in case you're looking for other HTML5 features as well. 回答2: Detecting "draggable' in document