literals

Why must a string be constructed at run-time? [duplicate]

喜欢而已 提交于 2019-12-10 01:07:22
问题 This question already has answers here : Is it possible to use std::string in a constexpr? (4 answers) Closed 4 years ago . Can C-Strings or std::string s be created as constexpr or must they be created at run-time? With gcc 4.9.2 I can do this: constexpr const char foo[] = "blee"; (Sadly the November 2013 Customer Technology Preview does not allow Visual Studio to support this: https://stackoverflow.com/a/29255013/2642059) But even with gcc 4.9.2 I cannot do this: constexpr const std::string

Max length of a string literal?

丶灬走出姿态 提交于 2019-12-09 17:51:50
问题 I am trying to create a long string literal, which I store inside a std::string. If I create a literal up to approximately 2600 characters, everything prints fine. If I go beyond that number of symbols, I only get some random garbage characters printed. I have been using the C standard as guidance, environmental limits are specified as "4095 characters in a string literal (after concatenation)". But the code is written in C++. So my question is, what is the minimum amount of characters in a C

Set ASP Literal text with Javascript

这一生的挚爱 提交于 2019-12-09 17:02:50
问题 I have an asp:Literal on my page ( which cannot be converted to a Label or any other control ) that I need to change the text of via JavaScript. I have the following code that works for a Label . Can anybody help? <script type="text/javascript"> function changeText() { document.getElementById('<%= Test.ClientID %>').innerHTML = 'New Text'; } </script> <a href="#" onclick='changeText()'>Change Text</a> <asp:Label id="Test" runat="server" Text="Original Text" /> Thanks UPDATE: I cannot change

How exactly does the JavaScript expression [1 [{}]] parse?

故事扮演 提交于 2019-12-09 12:41:30
问题 Can you explain how the JavaScript expression: [1 [{}]] parses/evaluates? In Firefox, Chrome, Konqueror, and rhino, it seems to create an array with a single element, undefined . However, I don't understand why. In Firefox: [1 [{}]].toSource() produces [(void 0)] Replacing 1 with other JavaScript values seems to yield the same result. Update: I think I understand now. codeka, Adrian, and CMS clarified things. As far as the standard, I tried to walk through ECMAScript 5. 1 [{}] is a Property

How does intern work in the following code?

…衆ロ難τιáo~ 提交于 2019-12-09 03:36:28
问题 String a = "abc"; String b = a.substring(1); b.intern(); String c = "bc"; System.out.println(b == c); The question might be foolish as intern has no major usage here, still I am confused about the fact, why does b == c results true . When String b = a.substring(1) is executed, String b references to object having "bc" Does b.intern create the literal "bc" in String Constant pool, even if it does, how come b==c result in true ? 回答1: String b = a.substring(1); returns string instance which

Difference between GCC binary literals and C++14 ones?

前提是你 提交于 2019-12-08 22:23:58
问题 C++14 seems to be coming and compilers are already trying to implement the core features of this new revision. I was having a look at GCC support for these core features and noticed something about the binary literals part: GCC implements them but seems to make a difference between GNU binary literals and C++14 binary literals. Here are the respective references for both: GNU binary literals C++1y binary literals I tried to find some differences between the two of them since GCC seems to make

Japanese COBOL Code: rules for G literals and identifiers?

↘锁芯ラ 提交于 2019-12-08 16:37:26
问题 We are processing IBMEnterprise Japanese COBOL source code. The rules that describe exactly what is allowed in G type literals, and what are allowed for identifiers are unclear. The IBM manual indicates that a G'....' literal must have a SHIFT-OUT as the first character inside the quotes, and a SHIFT-IN as the last character before the closing quote. Our COBOL lexer "knows" this, but objects to G literals found in real code. Conclusion: the IBM manual is wrong, or we are misreading it. The

In C how to loop for each enumerated literal where the literals do't have consecutive values

狂风中的少年 提交于 2019-12-08 06:03:48
问题 Suppose i have the following enumerated literal enum { valueA = 5, valueB = 7, valueC = 9, valueD = 14, valueE = 15 }myEnumType; and i want to loop through each literal eg for (enumType myValEnum = valueA; myValEnum <= valueE; myValEnum++) { MyFunction(mValEnum); } will that work or will I end up calling MyFunction with values 5,6,7,8,9,10,11,12,13,14,15 ? 回答1: You can't do that, there's no support for a "foreach" type of iteration over the enumeration in C. Basically, enumerations are just

Django IN query as a string result - invalid literal for int() with base 10

折月煮酒 提交于 2019-12-08 04:27:56
问题 Trying to query a 'Favorites' model to get a list of items a user has favorited, and then querying against a different model to get the objects back from that query to present to the template, but I'm getting an error: "invalid literal for int() with base 10" Looking over all of the other instances of that error, I couldn't find any in which the asker actually wanted to work with a comma separated list of integers, so I'm kind of at a loss. Model class Favorite(models.Model): # key should be

Want to access literal value into javascript

随声附和 提交于 2019-12-08 04:11:11
问题 I have got a literal control on page (with some data on it). i want to access it in javascript and want to put some text on it. please tell me how can i access literal control in JavaScript. I was trying with following code- <asp:Literal ID="lblPerInstanceListing" runat="server"></asp:Literal> Javascript: var value= document.getElementById('<%=lblPerInstanceListing.ClientID %>') I am getting null value return by this. 回答1: An ASP.NET Literal control does not by itself insert any HTML into a