Paavo Helde <myfirstname@osa.pri.ee>: Sep 20 09:08AM +0300 On 20.09.2019 1:22, Soviet_Mario wrote: > enumerated type operand). > How to circumvent the limitation without again "wrapping" another > std::string around the char * ? You cannot overload operators on built-in types like raw pointers. That's basically what the error message tells you. > I'd have thought that the std::string return type required could have > been enough, but it had not :\ Return value type is not used for overload deduction. > strings in a sequence, with at least one STD::STRING somewhere in the > sequence, but also one or more simple native literals (CHAR *) > consecutive in it. This is currently working: #include <string> using namespace std::literals::string_literals; std::string foo() { return "full "s + "moon"s; } std::string bar(const char* a, const char* b) { return ""s + a + b; } |
Bo Persson <bo@bo-persson.se>: Sep 20 11:52AM +0200 On 2019-09-20 at 00:22, Soviet_Mario wrote: > strings in a sequence, with at least one STD::STRING somewhere in the > sequence, but also one or more simple native literals (CHAR *) > consecutive in it. If the strings ARE literals, you don't even need the + to concatenate them. Consecutive literals are combined by the preprocessor: std::string s = "Hello" ", " "World!"; |
Soviet_Mario <SovietMario@CCCP.MIR>: Sep 20 06:05PM +0200 On 20/09/2019 08:08, Paavo Helde wrote: > std::string foo() { > return "full "s + "moon"s; > } what's the meaning of that suffix 's' after the literal char string ? I've never seen that modifier :\ > std::string bar(const char* a, const char* b) { > return ""s + a + b; > } I was trying to call functions via binary operator for brevity and clearness of the notation. Via function call synthax I would not have met the problems mentioned. I understand now there seem not to be a simple workaround, alas :( -- 1) Resistere, resistere, resistere. 2) Se tutti pagano le tasse, le tasse le pagano tutti Soviet_Mario - (aka Gatto_Vizzato) |
Soviet_Mario <SovietMario@CCCP.MIR>: Sep 20 06:09PM +0200 On 20/09/2019 11:52, Bo Persson wrote: > concatenate them. Consecutive literals are combined by the > preprocessor: > std::string s = "Hello" ", " "World!"; no, actually a mixture of std::string variables and some literals, to build variable error messages. I'd like a uniform notation when mixing this sort of data ... but not functional notation, rather heavy when chaining a lot of small fragments. I'm trying to avoid per-use of sprintf and asprintf ... maybe I'll have to resort to them. The format string is rather obscure, but later the comma notation of the variadic list is very short and clear. -- 1) Resistere, resistere, resistere. 2) Se tutti pagano le tasse, le tasse le pagano tutti Soviet_Mario - (aka Gatto_Vizzato) |
Keith Thompson <kst-u@mib.org>: Sep 20 11:31AM -0700 Soviet_Mario <SovietMario@CCCP.MIR> writes: [...] > what's the meaning of that suffix 's' after the literal char > string ? I've never seen that modifier :\ It was added in C++14. https://en.cppreference.com/w/cpp/string/basic_string/operator%22%22s -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */ |
Paavo Helde <myfirstname@osa.pri.ee>: Sep 20 09:52PM +0300 On 20.09.2019 19:05, Soviet_Mario wrote: > what's the meaning of that suffix 's' after the literal char string ? > I've never seen that modifier :\ I hoped that the line "using namespace std::literals::string_literals" would give a hint or at least provide something to google. But apparently not. Anyway, "abc"s is a std::string literal. You know, these are the kind of literals one should use in C++. The char* strings (and the problems with concatenating them) belong to another language which is supported for legacy only. If you just avoid using char* strings and literals your problem will disappear. |
Paavo Helde <myfirstname@osa.pri.ee>: Sep 20 09:55PM +0300 On 20.09.2019 19:09, Soviet_Mario wrote: > build variable error messages. > I'd like a uniform notation when mixing this sort of data ... but not > functional notation, rather heavy when chaining a lot of small fragments. I hope you are aware that you only need "functional notation" for the first string in the chain. |
Keith Thompson <kst-u@mib.org>: Sep 20 12:03PM -0700 > On 20.09.2019 1:22, Soviet_Mario wrote: [...] > std::string bar(const char* a, const char* b) { > return ""s + a + b; > } "..."s was added in C++14. If you can't rely on that, just ensure that the *first* argument in the chain of "+" operators is a std::string, not a C-style string or char*. As long as the left operand of each "+" is a std::string, it should work. There's (probably) no need to create a new overload. This works in C++14 and later: using namespace std::literals::string_literals; // ... std::cout << ""s + "hello" + ' ' + "world" + '\n'; In C++11 and later: std::cout << std::string{} + "hello" + ' ' + "world" + '\n'; In C++98 and later: std::cout << std::string() + "hello" + ' ' + "world" + '\n'; // OR std::cout << std::string("") + "hello" + ' ' + "world" + '\n'; -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */ |
Frederick Gotham <cauldwell.thomas@gmail.com>: Sep 20 07:24AM -0700 Some of you may vomit at my idea. . . But I don't want to go editing files all over the place... I only want to make an edit to one small little source file. So here's my idea. . . There's a function that must behave a little differently if it's called from a **particular** function in a **particular** thread. I can't change the file that the function is called from. In fact, I can only edit the small source file containing the called function. So here's what I'm thinking, add a little function: #include <cstdlib> /* free */ #include <cstring> /* strcmp */ #include <execinfo.h> /* backtrace, backtrace_symbols */ static bool Is_Called_From_Certain_Func(void) { void *bt[1024]; int const bt_size = backtrace(bt, 1024); char **const bt_syms = backtrace_symbols(bt, bt_size); bool retval = false; for (int i = 0; i < bt_size; ++i) { if ( 0 == std::strcmp("Some_Func", str_entry_point) ) { retval = true; break; } } std::free(bt_syms); return retval; } This will allow me to see if this function was called from a ***particular** function... and then I think I can use pthread functions to get the thread ID, and combine the two to see if the function should behave differently. thoughts? |
Frederick Gotham <cauldwell.thomas@gmail.com>: Sep 20 07:26AM -0700 > if ( 0 == std::strcmp("Some_Func", str_entry_point) ) Typo: "str_entry_point" should be "bt_syms[i]" |
Robert Wessel <robertwessel2@yahoo.com>: Sep 20 11:13AM -0500 On Fri, 20 Sep 2019 07:24:21 -0700 (PDT), Frederick Gotham >} >This will allow me to see if this function was called from a ***particular** function... and then I think I can use pthread functions to get the thread ID, and combine the two to see if the function should behave differently. >thoughts? Obviously any hope of that working is very implementation specific, and further, even GCC states that this may not work at optimization levels higher than -O0. Most notably, you may see omitted stack frames and inlined functions with any level of optimization, and thus the "calling" function may leave no trace on the stack at all. And, of course, backtrace_symbols won't work unless you've compiled with debug info. Perhaps some thread local storage to hold a flag might be a better option, although that has many of the same issues as any sort of global storage. |
Siri Cruise <chine.bleu@yahoo.com>: Sep 19 03:48PM -0700 In article <m6ydnRawy53gcB7AnZ2dnUU7-KvNnZ2d@giganews.com>, > Reals have no point immediately adjacent to 0.0, infinitesimals > name this point 0.0[1]. For positive reals exponents can be any reals, so that you can have a nondenumerable semi-open set of exponents A = [1, oo) and thus a nondenumerable semiopen set for real x X(x) = {x^a: 0<x<1, a in A} which has no minimum under < and a maximium of x. This is a nondenumerable version of an infinite strictly decreasing bounded sequence. To maintain definitions of exponentiation and less than for surreal infinitesimals, X(dx) for infinitesimal dx is also a nondenumerable subset of (0, dx]; thus a nondenumerable set separates 0.0 and dx. There is no point immediately adjacent to 0.0 even for surreals. You can, of course, define a set of infinitesimals which are not surreal, but it becomes your responsibility to prove your element 0.0[1] uniquely exists and can be meaningfully orderred among reals. I can define the set of all four corner triangles. However it is empty: it has no (unique) elements. I can also define < on naturals and < on triangles but that alone does not make 4 < triangle ABC a meaningful statement. -- :-<> Siri Seal of Disavowal #000-001. Disavowed. Denied. Deleted. @ 'I desire mercy, not sacrifice.' /|\ The first law of discordiamism: The more energy This post / \ to make order is nore energy made into entropy. insults Islam. Mohammed |
Siri Cruise <chine.bleu@yahoo.com>: Sep 19 03:57PM -0700 In article <UuadneUXFb9XQB7AnZ2dnUU7-dHNnZ2d@giganews.com>, > [0,1] - (0,1] = {0} a single point on the number line. > Thus proving a difference (in length) of one point between the first > interval and the second interval. You have to provide a length function and prove its properties. The best I can think of is d(S) = d(inf S, sup S). Since inf[0, 1] = inf(0, 1], under my definition d[0, 1] = d(0, 1]. I switch min to inf because you end up with lim d(x, 1], x/=0, x->0, and that's just a cladded definition of inf. -- :-<> Siri Seal of Disavowal #000-001. Disavowed. Denied. Deleted. @ 'I desire mercy, not sacrifice.' /|\ The first law of discordiamism: The more energy This post / \ to make order is nore energy made into entropy. insults Islam. Mohammed |
peteolcott <Here@Home>: Sep 19 06:00PM -0500 On 9/19/2019 5:48 PM, Siri Cruise wrote: > no (unique) elements. > I can also define < on naturals and < on triangles but that alone does not make > 4 < triangle ABC a meaningful statement. I don't pay any attention to any of these things. I simply derived a notational convention that allows all of the adjacent points on a number line to be directly referenced. I also proved why this is required in that Real numbers leave gaps in the number line with points that are unaccounted for. -- Copyright 2019 Pete Olcott All rights reserved "Great spirits have always encountered violent opposition from mediocre minds." Albert Einstein |
peteolcott <Here@Home>: Sep 19 06:10PM -0500 On 9/19/2019 5:57 PM, Siri Cruise wrote: > definition d[0, 1] = d(0, 1]. > I switch min to inf because you end up with lim d(x, 1], x/=0, x->0, and that's > just a cladded definition of inf. I don't understand any of that stuff. I do understand that (0, 1] is one point longer than (0, 1). Which entails that the definition of zero width points is incorrect. The first interval clearly has one more point than the second. The first interval also has a length of exactly 1.0 and the second interval has a length that is one point less than 1.0 because the missing point clearly has a numerical value that is greater than its predecessor. -- Copyright 2019 Pete Olcott All rights reserved "Great spirits have always encountered violent opposition from mediocre minds." Albert Einstein |
David Brown <david.brown@hesbynett.no>: Sep 20 08:52AM +0200 On 20/09/2019 01:00, peteolcott wrote: > I don't pay any attention to any of these things. I simply derived a > notational convention that allows all of the adjacent points on a number > line to be directly referenced. You don't seem to pay attention to anything much. Making up a notation is not the same as forming a mathematical theory. > I also proved why this is required in that Real numbers leave gaps > in the number line with points that are unaccounted for. You haven't proven anything. "Proof by repeated assertion" is not valid in mathematics. Perhaps the real people could give up this thread? I had hoped that there might be some interesting mathematics here, or even that PO could learn something. But while we have seen that there are people in c.l.c++ who are competent and interested in mathematics, I don't think there is anyone here with a hammer big enough to knock some sense through PO's thick skull. And his continued wilful ignorance makes it difficult to have an intelligent discussion on the topic (or anything else). |
Siri Cruise <chine.bleu@yahoo.com>: Sep 20 12:10AM -0700 In article <qm1svn$qe1$1@dont-email.me>, David Brown <david.brown@hesbynett.no> wrote: > > in the number line with points that are unaccounted for. > You haven't proven anything. "Proof by repeated assertion" is not valid > in mathematics. Infinity is counterintuitive. Nondenumerable infinite sets are doubleplus counterinitutive. God made integers; all else is the work of man. -- :-<> Siri Seal of Disavowal #000-001. Disavowed. Denied. Deleted. @ 'I desire mercy, not sacrifice.' /|\ The first law of discordiamism: The more energy This post / \ to make order is nore energy made into entropy. insults Islam. Mohammed |
Juha Nieminen <nospam@thanks.invalid>: Sep 20 08:06AM > longer than the second one. > The first interval begins at 0.0[0] and > The second interval begins at 0.0[1]. You didn't give a single property of that number. You only made claims about an interval. |
Juha Nieminen <nospam@thanks.invalid>: Sep 20 08:10AM >>> then all infinite sets have the same cardinality. >> They can't be. > I already proved this in other replies to you. No, you didn't. Making a claim is not a mathematical proof. |
David Brown <david.brown@hesbynett.no>: Sep 20 10:11AM +0200 On 20/09/2019 09:10, Siri Cruise wrote: >> in mathematics. > Infinity is counterintuitive. Nondenumerable infinite sets are doubleplus > counterinitutive. And the difference between infinite ordinals and infinite cardinals makes it even worse! > God made integers; all else is the work of man. I remember making Peano integers in a Haskell-like functional programming language. First year maths students made the integers - all else is the work of second or third year students! |
Juha Nieminen <nospam@thanks.invalid>: Sep 20 08:25AM > the number line indexed by integers. > Reals have no point immediately adjacent to 0.0, infinitesimals > name this point 0.0[1]. So you take an uncountable set, the set of reals, you add numbers to that set, and that somehow magically makes the set countable. And your proof of that is a simple assertion. You can't even provide a bijection between this expanded set of reals of yours, and the natural numbers. But surely it must be countable because you say it is. That's all the proof you need. Also, you can't give a single property of that "0.0[1]" number which distinguishes it from zero. |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Sep 20 01:18PM +0100 On 20/09/2019 00:10, peteolcott wrote: > I do understand that (0, 1] is one point longer than (0, 1). > Which entails that the definition of zero width points is incorrect. > The first interval clearly has one more point than the second. Your assertion in the form of an erroneous premise followed by an equally erroneous conclusion is, obviously, also erroneous. You don't get to define what is meant by a "geometric point"; we already have a well established and accepted definition for that concept. > second interval has a length that is one point less than 1.0 > because the missing point clearly has a numerical value that > is greater than its predecessor. More erroneous nonsense. You are either: 1) a troll; 2) a fucktard; or 3) not taking your medication. Which is it? /Flibble -- "Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin "You won't burn in hell. But be nice anyway." – Ricky Gervais "I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
David Brown <david.brown@hesbynett.no>: Sep 20 08:21AM +0200 On 19/09/2019 20:05, Bonita Montero wrote: >> - without an "__assume". That makes gcc a cooler compiler :-) > I just found the following: > gcc handles null-Pointers according to the standard: Good. > So on one side gcc is so clever as to assume that references > are never null, but on the other side you have no way to say > gcc that a pointer to be downcastet won't be null. Didn't you read the answer I gave you to your question "is there an equivalent to MSVC's __assume in gcc" ? Use that macro: D *f( B *b ) { assume(b); return static_cast<D *>(b); } f(B*): lea rax, [rdi-12] ret (Or write the __builtin_unreachable() directly, as Paavo did, if you prefer.) Thus (in this example) gcc gives you as good or better code for the plain C++, and gives you as good tools for giving the compiler extra information to generate more efficient results. I'm happy to see MSVC generating good code and providing useful extras - but it is nothing special here. (clang handles this like gcc.) |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment