« first day (1383 days earlier)      last day (2929 days later) » 
00:00 - 19:0019:00 - 00:00

19:01
OK I know about 'CodeReview', but I wasn't sure, if some specific C# method or something could solve this problem. — Majak 27 secs ago
C / C++ Question: Can someone PLEASE explain me why on Mother Earth I do get an error like error: no matching function for call to 'gethostbyname' here: dpaste.de/59nr ?
@Dex'ter Does it say more things?
@skiwi I just have another note which says: note: candidate function not viable: no known conversion from 'value_type' (aka 'std::__1::basic_string<char>') to 'const char *' for 1st argument struct hostent *gethostbyname(const char *);
So gethostbyname expects a const char* but you're providing a std::string?
yes, that's what I understand
19:07
0
Q: finding a text character through a set of rows

santuI am using below logic to search a phrase within a column "End phase". The data in the whole column identifies 9 phases from 1 to 9, each of these phases has to have phrase "end block". To split the data from 1 to 9 phases, I am using search and identify the phase ending. But the current logic s...

0
Q: Compatibility between Python 2.X and Python 3.X

tuliansI'm writing a program that needs to be compatible for both Python 2.X and Python 3.X. My problem is that, because of the differences between these two versions, I'm duplicating code. For example: try: ### Python 2.X part time.sleep(iterator.next()) if len(arguments) >= le...

@Dex'ter Well, then you should give one, right?
yea' I should convert each domain to a char* then pass it to gethostbyname
@Dex'ter std::string::c_str().
~~Depends on whether gehostbyname takes ownership of the char*.~~ It doesn't. Should be fine with c_str().
if ((h=gethostbyname(domains[i].c_str()) == NULL) {
    ...
Keep in mind that those functions are obsolete, though‌​.
@Zeta when I'm doing this I get: error: assigning to 'struct hostent *' from incompatible type 'bool'
what?
Did you miss a parentheses? Sounds like you've written h = (gethostbyname(...) == NULL).
19:15
C++ must have something similar to Java Stream's filter and C# LINQ's Where, right?
Hahahahahahahaha.
No.
Why :(
loop and an if statement :P
@skiwi Yes, it's called a for loop. ;)
Unless you mean remove_if or something like that.
Or copy_if.
19:16
Sounds like I may want to switch to Boost at some point then :/
@Zeta actually yes, I did
Essentially, the <algorithm> header has a lot of stuff.
But there's no stream-expression engine there.
@skiwi filter and where are ... quite fundamentally different, actually ...
Where's the catch?
@Vogel612 How so?
sure both take a predicate, but they operate on completely different premises
19:17
@Mast @Trojan404 Only 9 days of processing left!
Streams don't actually properly support generator expressions. The integration for streams into the language is klutzy as heck.
Now, the fun part. Making this multithreaded
@Dex'ter Years of reading bogus template error messages finally paid oSEGMENTATION FAULT
C# will happily take an IEnumerable where java only takes Iterables (which is not implemented by Stream mind you)
let's add to the mess, that java streams (because java) don't have actual proper generics
and those can make things quite a bit more complicated ..
@Zeta It's been several years since I've written some C / C++ code.
I just feel like a toddler who learns to walk for the first time
19:19
@skiwi But back to being serious: what do you want to do?
@Vogel612 I agree that Java Streams are not the most fun thing... Let's take a FP language as example too: (filter list pred) and it just works
@Zeta Filter a list on a predicate and return the result in a single line
A "list"?
What shall be the return value? A new list?
let's say std::vector
I mean a std::vector
(Why must every language name them differently)
@skiwi for (int i = 0; i < count; i++) { if (predicate) { newItems.Add(items[i]); } } ;)
One line. :P
19:21
That's not C++. :P
@Zeta It is if newItems is a std::vector and you replace predicate with the actual comparison.
auto result = copy_if(other, [](auto k) { return k > 10; });
Well, close.
.Add is probably push or something IIRC.
But I'm kidding.
@EBrown the problem is that that is eagerly evaluated, which is something you may want to avoid
19:22
That copy_if doesn't exist :/.
@Zeta and it won't ever in C++ if the language wants to keep it's place as a low-level language...
@Vogel612 That wasn't a requirement. @skiwi wanted to filter a list in a single line.
because you can't ever know how much memory you need to allocate beforehand (not that it matters to std::vector) ...
template <class T, class F>
T copy_if(const T & cont, F && f) {
    T result;
    copy_if(cont.cbegin(), cont.cend(), std::back_inserter(result), std::forward<F>(f));
    return result;
}
Argh, what's even the point of this: cplusplus.com/reference/algorithm/find_if
> Find element in range
Returns an iterator to the first element in the range [first,last) for which pred returns true. If no such element is found, the function returns last.
If I'm finding an element, then no, I don't want the last element to be returned if it cannot find anything!
19:24
[first, last) is an open range.
last is not an element of the container.
I'm voting to close this question as off-topic because it belongs on codereview.stackexchange.com — sds 21 secs ago
@Duga That doesn't make it off-topic for SO though...
@Zeta Oh... right, then it's definitely not what I want then
Ahem. See. Above. :D
I don't want to copy though
19:27
You said you want a new list o.O
Or vector. A new container.
Right... I may have said that :p
Why do you lie soooo often T_T
Do I need to implement operator == for every class I define myself? o.o
no ... only for those that need it ..
Ayup.
And you have to make sure that you follow the rule of five.
19:34
The rule of five?
The rule of three/five. Basically: if you define a custom constructor, you usually want a destructor and a copy constructor.
If you use C++11 and there's nothing suspicious going on, it might be as simple as YourClassName(const YourClassName&) = default;.
Tell me again why i'm not using Rust...
@Vogel612 Come to think about it… A #[derive(PartialEq,Eq)] for C++ would be great.
@skiwi Use in the industryyyyyyyyy.
(Imagine that I've sung that last word)
I'm tempted to build this DBMS in Rust too
Why is my code having so much issues if I try to be nice and add const where applicable
@skiwi Example error message + example code (that causes that error message)?
19:41
@Zeta do you know any fast alternative to this dpaste.de/0Had but without using that SFML thing ? I'm talking about the function which returns True if a port is opened and False otherwise
I just defined in my Database class for example: bool operator==(const Database& other)
And now in another file it complains when I want to compare two const db instances
@Dex'ter Do you want to build a portscanner? That's the second one I see today.
@skiwi You have to declare the function for const instances.
Maybe an issue is that I don't seem to understand how parameter& works yet
-1
Q: Anagram program in java

sakshiIn the given class COJ_06_Anagram.java, implement the method findAnagrams() such that it finds all anagram sets from a list of words.

@Zeta I've already built it, but in Python. Now I'm trying to do the same in C++ :P
19:42
Just wait a second. Need to prepare something.
It seems like I can use it without dereferencing manually?
... I don't have a editor.
Ah. Screw it. I use notepad.
//  the other may be const     vvvvvvv
bool operator==(const Database & other) const {
     // *this may be const              ^^^^^
}
@Dex'ter A fast alternative? Do you want to use raw sockets?
@Zeta Yes, a fast alternative.
SPAGHETTI CODE! :D
I don't know what any of this does but apparently I wrote it years ago. :D
In terms of execution speed, not writing speed, right? Huh. Hm. Well. It has been a while since I've used raw sockets.
19:47
I give up... for now, I've got other things to do
I can't even get this to work: databases = binary_read<std::vector<Database>>(&fs);
Where const std::vector<Database> databases;
> Updates
Best commit message ever.
@Zeta Exactly. The purpose it's to come up with a simple function which behaves like the one I pasted above (returns True if a port is opened and False otherwise) ^^
(That binary_read just returns std::vector<Database>)
@skiwi Have you removed const from that line?
And just use std::vector<Database> databases;?
@EBrown Then it works, but I want to know why
19:49
@skiwi Because you cannot assign to a const.
I'm stupid... Nvm
So when you declare databases as a const std::vector<Database> it is unassignable.
@EBrown Once assignable.
That clears a bunch of errors...
You can do const std::vector<Database> databases = binary_read<std::vector<Database>>(&fs); I think.
19:50
And only during initializiation. // see above.
Actually, that was the first assignment and it still didn't compile
@skiwi Possibly because it's not a constant.
Though later on I'm adding/removing to that vector so it needs to be non-const
@skiwi And the assignment has to be during the declaration.
Lastly, this one, but it may be messed up beyond repair:
void DeleteDatabase(const Database& database)
{
    for (const auto db : databases)
    {
        if (db == database)
        {
            databases.erase(database);
        }
    }
}
19:51
Your database doesn't have a copy constructor.
Both the == and .erase don't work
So I do need const auto&?
Wait. Where did you get the error again? Only in == and .erase? Not in for(const auto db : ...)?
@Zeta Correct
@skiwi Have you tried const Database db : databases?
@EBrown Yep, also fails
19:54
@skiwi Same spot, or different?
I may have messed up something beyond repair :D
@EBrown All the same
Complete source?
@Dex'ter I'm on Windows. Sorry. :/
0
Q: How I optimize the performance of this code?

DawarI have the following async ActionResult. public async Task<ActionResult> most_loved_pix() { var access_token = HttpContext.Items["access_token"].ToString(); if (!string.IsNullOrEmpty(access_token)) { Account account = new Account(); ...

It's multiple files, and not on Github yet, ugh :/
I don't really feel like sharing it though I know it's hard to get help then :D
@Zeta I'll get my head around it. (in a few hours) :P
19:56
To get things straight first: I want to be using & as much as possible, right? To prevent things from getting copied all the time
@skiwi I would really like to say yes, but it depends :/.
@Dex'ter 1. Get address info; 2. create socket. 3. connect.
But don't forget step 0: check that those library functions are safe for multi-thread programming.
@Zeta I'll try to keep that in mind
I'll just patiently wait until all my code breaks down :D
Hmmm, should I have put my == operator in the header file of Database?
The declaration, yes. Implementation can stay in your .cpp.
This might explain things...
20:01
monking
Monking janos
And I managed to create even more issues
        DBMS_EXPORTS_API Database& GetDatabase(const std::string file);

        DBMS_EXPORTS_API Database& GetDatabase(const std::string name);
I should probablya dd a ByFile and ByName
Monking @janos
You know, choosing a too ambitious first C++ program is like having to defend yourself in front of the Spanish inquisition, without actually knowing Spanish. You can just start talking and hope that they will spare you. Or you prepare yourself before you try to defend yourself.
It might've been too ambitious
I'm not sure there's a forum like that within the Stack Exchange system. The closest thing is the Code Review site but this isn't about code per-se, so... — tadman 49 secs ago
20:04
If I'm still stuck next week then I'll reconsider
stackoverflow is meant for specific questions with objective solutions. your code is syntactically correct and properly multiplies two arbitrary BigDecimal values together. if you want tips on how to improve your code, you should check out codereview.stackexchange.comeiko 26 secs ago
Don't give up yet. As I said, try to split the project into smaller parts. Build a proper serializer first. Or a table. Heck, even a single arbitrary-type cell can post a real challenge (if you want to use such a thing).
0
Q: Finding a text character through a set of rows

santuI am using below code to find a phrase "Phase End" in an excel column where the data exists from 1 to 9 phases. Problem is I can find phase 1 to 9 by its " Phase 1" "Phase 2" ... But all phases have the same ending phrases like "Phase End". When I do the search, is it possible to skip the ident...

off-topic?
might be ... seems grey to me, but I didn't VTC yet ...
I deemed it just a poor question, and yes, a bit too grey for my hammer
20:11
0
Q: Concurrency and locking in a chat server

Winger SendonI've never done concurrent programming before, but I've written one using go channels and RWMutex, but I'm not sure if my approach is idiomatic. I feel like it could all use channels (Maybe). The protocol is simple: Messages are delimited by '\n'. The first message client sends is it's name. The...

I find it's too broad. OP is not asking for improvements but for a completely new solution that he doesn't have yet and doesn't know how to do it.
20:33
Oh. Wow. I've accidentally installed rust via msys2. And here I wonder why my pacman -Syu takes so $#&% long.
Apparently, I've also installed emacs there. Now I have emacs twice. And vim thrice. My Windows package management is rubbish.
I've managed to do it :D
Now I just have to get rid of the rubbish things in my code
but if I do this I'll just have #includes left
grr ...
20:54
hmm, when I'm creating a socket, can I declare it outside the for loop and for each connection in the for loop to reuse it ? (after I'm closing it at the end of the for loop, of course)
21:04
I'm looking for a JavaScript master, or aspiring master. I friend of mine is learning JavaScript. On that path, he developed a Trello clone using React, and now he feels kind of stuck, not knowing what would be a good logical next step toward mastery. What would you advise?
This looks fine to me; I wouldn't have problems with this at code review. Only comment would be naming - maybe getFirst? Also would need to document that it will throw something if the thing is empty - which brings me to my final point; this doesn't compile - missing the name on the interface declaration. — Boris the Spider 50 secs ago
@Dex'ter If you're using socket(...), it's just an int.
0
Q: Tracking length of time a user stays on a page

ByteSettlementI am creating a system timer to track how long a user is on each page which is called a phase in my program. I am currently working on checking whether a object in my timer array contains the phase name for checking if they had to go back a page and spent more time on it and add it on to what wa...

@janos Not a master by any stretch but maybe they can look into server side Node? Write their own http server
@Phrancis Thanks Phrancis, sounds like a fine idea
21:26
I feel bad for people who started with C++ :P
Though the few that have survived are probably pretty good at programming
you don't even search for solution :( it's more simplest than you've write codereview.stackexchange.com/questions/102673/…Wizard 34 secs ago
0
Q: My Academic Standing calculator in HTML + Java Servlets

Kirill  KhlamovI'm trying to make the Academic Standing Calculator using HTML select box with options.The program should Display a list of the letter grades and their values and then save the selected values in the ArrayList as an object by clicking Save button, and after the user clicks "Done", the selected gr...

"I've a working solution, but I think it could be improved." Stack Overflow is primarily for questions about code that does not work. codereview.stackexchange.com might be a better place for your question, but you need to be more specific still. — Felix Kling 21 secs ago
@skiwi Depends how far they got.
> Severity Code Description Project File Line Suppression State
Error C2662 'const std::string DBMS::Database::GetFile(void)': cannot convert 'this' pointer from 'const DBMS::Database' to 'DBMS::Database &' DBMS c:\users\frank\dropbox\visual studio 2015\projects\dbms\dbms\dbms.cpp 122
Hum
Huh, now I"m curious, I fixed it by doing the following:
DBMS_EXPORTS_API const std::string GetFile() const;
I thought it had a const return type, but looks like it didn't have
Apparently they do both very different things
27
Q: Why using the const keyword before and after method or function name?

Vick_PkI have the following code in my application. Why do we use the const keyword with the return type and after the method name? const T& data() const { return data_; }

Ah cool, so you can make a const function that takes a const argument and returns a const result
21:34
@FelixKling thanks. I wasnt aware of codereview. I'll give it a try ! — nip 1 min ago
Taking a break sometimes helps :D
21:47
Got some mismatched header/source file method definitions, but it mostly works :)
22:05
possible answer invalidation by MathuSum Mut on question by MathuSum Mut: codereview.stackexchange.com/posts/155389/revisions
0
Q: C++ implementation of Kruskal's algorithm

theSongbirdI'm trying to implement Kruskal's algorithm. Here is a map of the structures I'm using: g = array of edges, it keeps the left end and the right end and the edge's weight; c = array which memorises the conex components; c[N] = the conex component in which we find the Nth vertex; a = array which...

Consider asking this at CodeReview. Additionally, you may want to format this a bit better. — Santi 7 secs ago
I'm voting to close this question as off-topic because it belongs on codereview.stackexchange.com — scsimon 42 secs ago
I also voted to move this to code review. Regardless of where this question is asked it is lacking any kind of details to be able to help. Performance of this query would likely take several hours to even start getting a picture of what is going on. And that is sitting with the database in front of you. There are just so many things that it could be...indexing, fragmentation, stale statistics, blocking, non-sargable predicates...etc. Just getting an estimated execution plan would probably help to start but this is a big ask of anybody. — Sean Lange 10 secs ago
22:28
@EBrown 9 more days of fun times
23:02
OK, why can't things just work?
I'm following all the rules for VisualStateManager, but it doesn't work.
Oh well, I'll just do it the ugly way.
I'll set all my values in code behind.
@Vogel612 I cast the first VTC for CNWY
23:28
0
Q: KMP Algorithm Implementation

user2218988I request that my code be reviewed for implementation and naming conventions. public int KMP(String txt, String pat) { int[] lcp = getlcp(pat); int i = 0, j = 0; while (i < txt.length() && j != pat.length()) { if (txt.charAt(i) == pat.charAt(j)) { j++; } ...

00:00 - 19:0019:00 - 00:00

« first day (1383 days earlier)      last day (2929 days later) »