Switch to DuckDuckGo Search
   July 17, 2019
< | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31

Toggle Join/Part | bottom
[00:01:54] *** m_ben <m_ben!~m_ben@unaffiliated/m-ben/x-5917362> has quit IRC (Quit: WeeChat 2.5)
[00:02:24] *** kitsunenokenja <kitsunenokenja!~kitsunech@68.91.220.96> has quit IRC (Ping timeout: 272 seconds)
[00:02:57] *** drs <drs!~devin@cpe-104-33-56-3.socal.res.rr.com> has joined ##C++-general
[00:03:44] *** Moto-chan <Moto-chan!~rob@unaffiliated/moto-chan> has quit IRC (Remote host closed the connection)
[00:07:53] *** sonOfRa <sonOfRa!sonOfRa@unaffiliated/sonofra> has quit IRC (Remote host closed the connection)
[00:09:49] *** LunarJetman <LunarJetman!LunarJetma@94.14.216.120> has quit IRC (Quit: LunarJetman)
[00:10:43] *** sonOfRa <sonOfRa!sonOfRa@unaffiliated/sonofra> has joined ##C++-general
[00:13:12] *** goiko <goiko!~goiko@pD958302F.dip0.t-ipconnect.de> has joined ##C++-general
[00:13:12] *** goiko <goiko!~goiko@pD958302F.dip0.t-ipconnect.de> has quit IRC (Changing host)
[00:13:13] *** goiko <goiko!~goiko@unaffiliated/goiko> has joined ##C++-general
[00:28:22] *** giaco <giaco!~jack@2-238-151-49.ip244.fastwebnet.it> has quit IRC (Ping timeout: 272 seconds)
[00:31:36] *** vdamewood <vdamewood!~vdamewood@unaffiliated/vdamewood> has quit IRC (Quit: Life beckons)
[00:31:55] <Onionnion> Is there a way to make this work? To call end() on an array defined outside of the current scope? https://www.irccloud.com/pastebin/17BzlVh2/
[00:32:02] <Onionnion> Currently compiles with: no matching function for call to ‘end(char*&)’
[00:33:04] <Onionnion> Or should end() not be used like that at all
[00:34:55] <snyp> Onionnion: take the given array via `char &a[10]` type, or something like that.
[00:35:02] <snyp> Or just use std::array.
[00:36:51] *** fogbank <fogbank!~fogbank@net-37-116-100-33.cust.vodafonedsl.it> has joined ##C++-general
[00:38:02] <Onionnion> You mean like void foo(char &a[10]); ?
[00:39:07] <Svitkona> void foo(char (&a)[10]) { ... } , but yes
[00:39:34] <snyp> Yeah. If you're not going to use std::array, you could just pass pointer and a count. I prefer that. Pointers are usable as iterators.
[00:40:17] <Onionnion> Yeah I probably should use std::array instead, was going into the project new to C++ still
[00:41:08] <Onionnion> That works Svitkona thanks
[00:45:02] *** kitsunenokenja <kitsunenokenja!~kitsunech@68.91.220.96> has joined ##C++-general
[00:45:48] *** gehn <gehn!gehn@gateway/vpn/privateinternetaccess/gehn> has quit IRC (Quit: Leaving)
[00:47:12] <Onionnion> Should I be able to pass it in with foo(a); ?
[00:47:40] <Onionnion> Trying different things but getting errors on that part
[00:48:38] <Onionnion> My IDE wants me to do: reinterpret_cast<char (&)[10]>(a)
[00:49:54] <Onionnion> Oh nevermind it's just with my specific actual code where I'm passing in a constant to the size instead and IDE doesn't like that
[00:50:43] <RandomReader> it has to be a compile-time known size, this isn't valid for variable array sizes
[00:50:55] <RandomReader> if that's what you're after, then you'll need a different container
[00:51:44] *** giaco <giaco!~jack@2-238-151-49.ip244.fastwebnet.it> has joined ##C++-general
[00:51:46] *** Kronuz <Kronuz!~Kronuz@unaffiliated/kronuz> has joined ##C++-general
[00:51:57] <RandomReader> vector is a common one, but it'd depend on the actual use case
[00:52:46] <RandomReader> or as snyp said just work with pointers and offsets instead of begin/end
[00:54:24] <Onionnion> I got it to work now after refreshing it, it's a constexpr with how I'm setting the size of the char*
[00:54:54] <Onionnion> Beta version of CLion tends to be buggy
[00:54:58] <RandomReader> ah, that sounds ok
[00:56:23] <Onionnion> I probably should look into using std::array instead
[00:57:26] <RandomReader> I prefer it over bare arrays for most uses
[00:58:03] <Onionnion> Main reason for using this is the library I'm using is in C and uses raw pointers
[00:58:20] <Onionnion> Is there an easy way to use std::array or std::string with those kind of functions?
[00:59:01] <Onionnion> The ones where they input a pointer and make changes to or read its data
[00:59:04] <RandomReader> .data() or std::data()
[00:59:50] <RandomReader> works for the sequential containers like array/string/vector
[01:00:55] <RandomReader> well, and &container[0] also works, I just find it uglier :P
[01:01:16] *** Forsaken87 <Forsaken87!~quassel@2a02:908:1861:340:3f50:ee15:aa6:ab4d> has quit IRC (Ping timeout: 264 seconds)
[01:03:35] *** Sollg3r <Sollg3r!~ejakuk@201.22.211.59.dynamic.adsl.gvt.net.br> has joined ##C++-general
[01:07:01] <Onionnion> Ahh wish I knew about that sooner because it'd make this much easier heh
[01:07:07] <Onionnion> think I'll try it
[01:08:40] <Onionnion> Is there any reason to not use `using namespace std;` to avoid having to put std:: in front of everything?
[01:09:29] <RandomReader> https://stackoverflow.com/q/1452721
[01:10:05] <RandomReader> it's a judgment call for source files or inside block scope (like a function), but that should give you enough information to make that call
[01:10:14] <RandomReader> doing it inside headers is pretty much all bad
[01:12:04] *** SwiftMatt <SwiftMatt!~Objective@2601:282:4300:3e:4489:7814:51a7:30b7> has joined ##C++-general
[01:12:09] *** Jitta <Jitta!~Jitta@ip5b41c62d.dynamic.kabel-deutschland.de> has joined ##C++-general
[01:13:22] *** queip <queip!~queip@unaffiliated/rezurus> has quit IRC (Ping timeout: 245 seconds)
[01:14:13] *** drincruz_ <drincruz_!~drincruz@144.121.100.66> has quit IRC (Ping timeout: 246 seconds)
[01:18:26] *** queip <queip!~queip@unaffiliated/rezurus> has joined ##C++-general
[01:18:39] <computerquip> And yet... people still do it all the time. I feel like it should be a compiler warning.
[01:19:50] <Onionnion> Does std::string always guarantee a '\0' at the end of it?
[01:20:14] <RandomReader> yes
[01:21:45] <computerquip> C++11 onwards. C++03 did not.
[01:22:03] <RandomReader> if you're using it as an output buffer or otherwise expect the C library to change the logical length of what's stored in it, you'll want to do a .resize(strlen(.data())) kind of thing afterward
[01:22:05] <computerquip> I don't know of an implementation that didn't null-terminate it but wasn't guaranteed.
[01:22:32] *** Joey172 <Joey172!~Joey172@74.116.154.10> has quit IRC (Ping timeout: 268 seconds)
[01:27:22] <Onionnion> What I currently have is std::ifstream reading into some char* with a const being used to read a specific number of bytes, should I do that if I'm reading it now into a .data() of a std::string or is there a better way to do this instead?
[01:28:16] <Onionnion> const being used to say how many bytes to read*
[01:31:44] <Onionnion> Trying to google it but getting unrelated answers about entire files or line-by-line
[01:33:12] <RandomReader> if you're wanting to deal with specific sized chunks, yeah that seems appropriate .. create the appropriately sized std::string and ifstream.read(str.data(), str.size())
[01:33:30] *** Jitta <Jitta!~Jitta@ip5b41c62d.dynamic.kabel-deutschland.de> has quit IRC ()
[01:34:48] *** atomicity|phone <atomicity|phone!~atomicity@cpc73844-dals21-2-0-cust776.20-2.cable.virginm.net> has joined ##C++-general
[01:40:08] *** Joey172 <Joey172!~Joey172@74.116.154.10> has joined ##C++-general
[01:40:53] *** xekz <xekz!~kexmex@unaffiliated/kexmex> has joined ##C++-general
[01:44:04] *** Woodpecker <Woodpecker!uid241015@gateway/web/irccloud.com/x-xydhptwzcojroogn> has joined ##C++-general
[01:49:25] <Onionnion> Just wanted to make sure it wasn't breaking an better or best practices
[01:49:38] <Onionnion> There are so many possible ways to do things in this I'm left uncertain what's the best way
[01:50:13] *** joe4 <joe4!~joe@unaffiliated/th3-g0d5> has joined ##C++-general
[01:50:19] *** mpersano <mpersano!~mauro@177.32.193.126> has quit IRC (Quit: leaving)
[01:53:00] *** tomboy64 <tomboy64!~tomboy64@gateway/tor-sasl/tomboy64> has quit IRC (Ping timeout: 260 seconds)
[01:53:03] <RandomReader> aye, and frankly the streams interface in general doesn't help much here .. it's old and we'd prefer other ways at this point, they just don't exist
[01:54:08] *** tomboy64 <tomboy64!~tomboy64@gateway/tor-sasl/tomboy64> has joined ##C++-general
[02:01:06] *** kitsunenokenja <kitsunenokenja!~kitsunech@68.91.220.96> has quit IRC (Ping timeout: 248 seconds)
[02:01:06] *** de-facto <de-facto!~de-facto@gateway/tor-sasl/de-facto> has quit IRC (Quit: See you around.)
[02:01:29] *** de-facto <de-facto!~de-facto@gateway/tor-sasl/de-facto> has joined ##C++-general
[02:01:44] <Onionnion> yeah found one answer using std::stringstream but this is easier anyway
[02:02:18] *** snyp <snyp!~Snyp@106.51.18.66> has quit IRC (Quit: WeeChat 2.5)
[02:03:23] <Onionnion> Should I also always .close() all my std::ifstream or std::ofstream objects or should that be done automatically when the scope they were created in is left?
[02:03:45] <RandomReader> it's done automatically when they leave scope, and it's preferred to rely on that
[02:03:46] <InPhase> Onionnion: If you're reading directly into .data(), this doesn't guarantee the \0. You need to put it there manually.
[02:04:22] <RandomReader> use .close() if you need to close/reopen/whatever "early" and the scope isn't appropriate for that
[02:04:29] <Onionnion> Thanks
[02:05:16] <RandomReader> well, for std::string the \0 will be at the end of the sized block you requested, so there'll be two possibilities: you read the entire block in which case it's there and everything is fine, or you read less and you'll .resize() the string based on .gcount(), and it'll put it in the right spot as part of that
[02:05:29] <RandomReader> if you use a different container like vector, you'd need to manually manage the \0
[02:05:35] <Onionnion> InPhase: I was thinking about that but I should be good here because I'm creating the std::string with a specific size then reading only that number of characters in so the '\0' should still be there at the end
[02:05:57] <InPhase> If you are mindful of RandomReader's caveat.
[02:06:24] <Onionnion> yeah RandomReader's first answer is what I have
[02:07:28] *** joe4 <joe4!~joe@unaffiliated/th3-g0d5> has quit IRC (Ping timeout: 258 seconds)
[02:08:15] <RandomReader> (!ifstream) or otherwise testing for fail/eof should be enough to know you should check/resize based on .gcount
[02:08:40] <RandomReader> or just if (!ifstream.read(...)) I suppose
[02:11:05] *** snyp <snyp!~Snyp@106.51.18.66> has joined ##C++-general
[02:13:23] *** gopar_ <gopar_!~gopar@c-73-170-87-34.hsd1.ca.comcast.net> has quit IRC (Remote host closed the connection)
[02:14:40] *** joe4 <joe4!~joe@unaffiliated/th3-g0d5> has joined ##C++-general
[02:14:58] *** yawkat <yawkat!~yawkat@cats.coffee> has quit IRC (Ping timeout: 248 seconds)
[02:23:00] *** serviscope_minor <serviscope_minor!~Telequipm@88.97.56.26> has quit IRC (Ping timeout: 272 seconds)
[02:23:42] *** mad_enz <mad_enz!~mad_enz@2606:6d00:135:9d84:3014:34ea:1585:887b> has quit IRC (Read error: Connection timed out)
[02:24:24] *** mad_enz <mad_enz!~mad_enz@2606:6d00:135:9d84:3014:34ea:1585:887b> has joined ##C++-general
[02:26:07] *** yawkat <yawkat!~yawkat@cats.coffee> has joined ##C++-general
[02:37:20] *** Atlenohen <Atlenohen!~Walter@cpe-86-58-57-5.static.triera.net> has quit IRC (Quit: Shutdown - Closing IRC)
[02:40:27] *** snyp <snyp!~Snyp@106.51.18.66> has quit IRC (Ping timeout: 245 seconds)
[02:41:42] *** Joey172 <Joey172!~Joey172@74.116.154.10> has quit IRC (Ping timeout: 245 seconds)
[02:42:03] *** martylake_ <martylake_!~martylake@x2f7f896.dyn.telefonica.de> has joined ##C++-general
[02:46:22] *** martylake <martylake!~martylake@2a01:c22:b02f:2000:6130:edb9:95c9:f7cb> has quit IRC (Ping timeout: 276 seconds)
[02:47:40] *** SwiftMatt <SwiftMatt!~Objective@2601:282:4300:3e:4489:7814:51a7:30b7> has quit IRC (Ping timeout: 276 seconds)
[02:48:53] *** SwiftMatt <SwiftMatt!~Objective@2601:282:4300:3e:10dc:86b3:bc0b:b322> has joined ##C++-general
[02:52:02] *** martylake_ <martylake_!~martylake@x2f7f896.dyn.telefonica.de> has quit IRC (Read error: Connection reset by peer)
[02:55:57] *** gopar_ <gopar_!~gopar@c-24-5-140-55.hsd1.ca.comcast.net> has joined ##C++-general
[03:09:55] *** xekz <xekz!~kexmex@unaffiliated/kexmex> has quit IRC (Quit: My MacBook has gone to sleep. ZZZzzz…)
[03:12:04] *** Joey172 <Joey172!~Joey172@99-56-212-234.lightspeed.gdrpmi.sbcglobal.net> has joined ##C++-general
[03:13:00] *** Joey172 <Joey172!~Joey172@99-56-212-234.lightspeed.gdrpmi.sbcglobal.net> has quit IRC (Remote host closed the connection)
[03:13:59] *** Joey172 <Joey172!~Joey172@99-56-212-234.lightspeed.gdrpmi.sbcglobal.net> has joined ##C++-general
[03:16:08] *** gopar_ <gopar_!~gopar@c-24-5-140-55.hsd1.ca.comcast.net> has quit IRC (Remote host closed the connection)
[03:20:26] *** pulse <pulse!~pulse@unaffiliated/pulse> has quit IRC (Quit: pulse)
[03:25:58] *** chris-bode <chris-bode!~Thunderbi@ool-182d2832.dyn.optonline.net> has quit IRC (Quit: chris-bode)
[03:26:32] *** fuze <fuze!uid76888@gateway/web/irccloud.com/x-apptdllgbapwjvqp> has joined ##C++-general
[03:39:25] *** wondows <wondows!be202134@190.32.33.52> has quit IRC (Remote host closed the connection)
[03:42:19] *** lh_mouse <lh_mouse!~lh_mouse@unaffiliated/lh-mouse/x-3986007> has joined ##C++-general
[03:42:41] *** arch-1980 <arch-1980!~arch@93.114.71.39> has joined ##C++-general
[03:45:02] *** arch-1980 <arch-1980!~arch@93.114.71.39> has quit IRC (Remote host closed the connection)
[03:46:42] *** joe4 <joe4!~joe@unaffiliated/th3-g0d5> has quit IRC (Ping timeout: 248 seconds)
[03:48:52] *** snyp <snyp!~Snyp@106.51.18.66> has joined ##C++-general
[03:50:01] *** Sollg3r <Sollg3r!~ejakuk@201.22.211.59.dynamic.adsl.gvt.net.br> has quit IRC (Quit: Leaving)
[03:50:42] *** BOKALDO <BOKALDO!~BOKALDO@81.198.21.178> has joined ##C++-general
[03:51:02] *** npaperbot <npaperbot!~npaperbot@dodecahedron.m-ou.se> has quit IRC (Remote host closed the connection)
[03:51:11] *** npaperbot <npaperbot!~npaperbot@dodecahedron.m-ou.se> has joined ##C++-general
[03:54:12] *** snyp <snyp!~Snyp@106.51.18.66> has quit IRC (Ping timeout: 272 seconds)
[03:57:50] *** nullcone <nullcone!uid11626@gateway/web/irccloud.com/x-kqseubuumamptsct> has joined ##C++-general
[04:02:22] *** lh_ideapad <lh_ideapad!~lh_mouse@unaffiliated/lh-mouse/x-3986007> has joined ##C++-general
[04:05:57] *** queip <queip!~queip@unaffiliated/rezurus> has quit IRC (Ping timeout: 268 seconds)
[04:10:05] *** Miroboru <Miroboru!~myrvoll@133.58.119.8> has joined ##C++-general
[04:11:25] *** queip <queip!~queip@unaffiliated/rezurus> has joined ##C++-general
[04:12:49] *** hs_ <hs_!~hs_@2605:e000:1b04:358:8ce:64a:8c70:19b> has quit IRC (Ping timeout: 276 seconds)
[04:15:31] *** Kelzorz <Kelzorz!~Kelzorz@162.104.220.155> has quit IRC (Ping timeout: 246 seconds)
[04:15:51] *** etwert <etwert!~hgfdfgh@77.243.25.234> has quit IRC (Quit: Leaving)
[04:18:08] *** Sollg3r <Sollg3r!~ejakuk@201.22.211.59.dynamic.adsl.gvt.net.br> has joined ##C++-general
[04:18:30] *** royal_screwup21 <royal_screwup21!a11734b1@gateway/web/cgi-irc/kiwiirc.com/ip.161.23.52.177> has quit IRC (Quit: Ping timeout (120 seconds))
[04:19:50] *** Koopa_ <Koopa_!~Koopa__@ool-457c9a21.dyn.optonline.net> has joined ##C++-general
[04:20:36] *** z8z <z8z!~x@ac230029.ppp.asahi-net.or.jp> has quit IRC (Quit: Quitting)
[04:25:01] *** hs_ <hs_!~hs_@2605:e000:1b04:358:2dfa:e5a0:ec9d:2eda> has joined ##C++-general
[04:36:18] *** cbreak <cbreak!~cbreak@77-58-201-132.dclient.hispeed.ch> has quit IRC (Read error: Connection reset by peer)
[04:36:32] *** Ingersol <Ingersol!~Ingersol@93.116.234.146> has joined ##C++-general
[04:37:29] *** cbreak <cbreak!~cbreak@77-58-201-132.dclient.hispeed.ch> has joined ##C++-general
[04:42:57] *** savolla <savolla!~savolla@95.10.238.253> has quit IRC (Ping timeout: 245 seconds)
[04:46:14] *** wildlander_ <wildlander_!~wildlande@182.83-213-84.dynamic.clientes.euskaltel.es> has joined ##C++-general
[04:46:27] *** Gyro <Gyro!~user@x4d03a489.dyn.telefonica.de> has joined ##C++-general
[04:46:42] *** wildlander <wildlander!~wildlande@unaffiliated/wildlander> has quit IRC (Ping timeout: 245 seconds)
[04:48:00] *** de-facto <de-facto!~de-facto@gateway/tor-sasl/de-facto> has quit IRC (Ping timeout: 260 seconds)
[04:49:27] *** de-facto <de-facto!~de-facto@gateway/tor-sasl/de-facto> has joined ##C++-general
[04:56:34] *** Joey172 <Joey172!~Joey172@99-56-212-234.lightspeed.gdrpmi.sbcglobal.net> has quit IRC (Ping timeout: 248 seconds)
[04:57:35] *** B1ackV3nom <B1ackV3nom!~B1ackWid0@gateway/tor-sasl/b1ackwid0w> has quit IRC (Quit: B1ackV3nom)
[04:58:06] *** Sollg3r <Sollg3r!~ejakuk@201.22.211.59.dynamic.adsl.gvt.net.br> has quit IRC (Quit: Leaving)
[05:02:02] *** kitsunenokenja <kitsunenokenja!~kitsunech@68.91.220.96> has joined ##C++-general
[05:03:44] *** Woodpecker <Woodpecker!uid241015@gateway/web/irccloud.com/x-xydhptwzcojroogn> has quit IRC (Quit: Connection closed for inactivity)
[05:04:09] *** fc5dc9d4 <fc5dc9d4!~quassel@p5B08187F.dip0.t-ipconnect.de> has joined ##C++-general
[05:08:51] *** fc5dc9d4_ <fc5dc9d4_!~quassel@p5B08151A.dip0.t-ipconnect.de> has quit IRC (Ping timeout: 268 seconds)
[05:12:48] *** Roughy <Roughy!~mdaw45ns@188.126.202.174> has quit IRC (Quit: Meadow Fresh milk)
[05:16:07] <Koopa_> I posted this in #cmake, but I feel it could get some more attention here - I'm having some trouble with the CheckCXXCompilerFlag CMake module. When I call check_cxx_compiler_flag() for the "-Werror" flag with GCC 9.1.0, the variable is set as true, but when I do the same for Clang 8.0.0, the variable remains unset.
[05:16:40] *** gopar_ <gopar_!~gopar@2601:647:4700:fd6d:7991:2dbb:6292:7ef7> has joined ##C++-general
[05:19:50] *** quarterback <quarterback!~quarterba@223.196.163.212> has joined ##C++-general
[05:19:50] *** quarterback <quarterback!~quarterba@223.196.163.212> has quit IRC (Changing host)
[05:19:50] *** quarterback <quarterback!~quarterba@unaffiliated/quarterback> has joined ##C++-general
[05:21:43] *** gopar_ <gopar_!~gopar@2601:647:4700:fd6d:7991:2dbb:6292:7ef7> has quit IRC (Ping timeout: 276 seconds)
[05:22:15] *** Kelzorz <Kelzorz!~Kelzorz@162.104.220.155> has joined ##C++-general
[05:23:40] *** purplex88 <purplex88!~purplex88@unaffiliated/purplex88> has joined ##C++-general
[05:41:01] *** Kaslai <Kaslai!~Kaslai@www.frogbox.es> has quit IRC (Changing host)
[05:41:01] *** Kaslai <Kaslai!~Kaslai@unaffiliated/kaslai> has joined ##C++-general
[05:43:35] *** tm <tm!~sinnlos@unaffiliated/tm> has quit IRC (Ping timeout: 244 seconds)
[05:48:33] *** tm <tm!~sinnlos@unaffiliated/tm> has joined ##C++-general
[05:50:06] *** Onionnion <Onionnion!uid114144@gateway/web/irccloud.com/x-nbrlchxwgshtpemo> has quit IRC (Quit: Connection closed for inactivity)
top

   July 17, 2019
< | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31