Tuesday, March 3, 2020

Digest for comp.lang.c++@googlegroups.com - 12 updates in 5 topics

Daniel <danielaparker@gmail.com>: Mar 03 07:16AM -0800

Consider two overloads of the std::directory_iterator constructor,
 
explicit directory_iterator(const std::filesystem::path& p); // (1a)
 
directory_iterator(const std::filesystem::path& p,
std::error_code& ec); // (1b)
 
(1a), which throws, and (1b), which takes a std::error_code& parameter.
 
Now, suppose directory_iterator were to have an overload that took an
allocator parameter. It doesn't, but suppose that it did. Consistent with
Standard Library design guidelines, such as they are, which overload
would you expect to see
 
directory_iterator(const std::filesystem::path& p,
const Allocator& alloc = Allocator()); // (2a)
 
directory_iterator(const std::filesystem::path& p,
const Allocator& alloc,
std::error_code& ec); // (2b)
 
or
 
directory_iterator(const std::filesystem::path& p,
const Allocator& alloc = Allocator()); // (3a)
 
directory_iterator(const std::filesystem::path& p,
std::error_code& ec,
const Allocator& alloc = Allocator()); // (3b)
 
or
 
directory_iterator(std::allocator_arg_t,
const Allocator& alloc,
const std::filesystem::path& p); // (4a)
 
directory_iterator(std::allocator_arg_t,
const Allocator& alloc,
const std::filesystem::path& p,
std::error_code& ec); // (4b)
 
 
(2b) doesn't follow any of the user-allocator construction conventions,
https://en.cppreference.com/w/cpp/memory/uses_allocator#Uses-allocator_construction. (3b) looks disjointed.
 
Thanks,
Daniel
Daniel <danielaparker@gmail.com>: Mar 03 08:08AM -0800

On Tuesday, March 3, 2020 at 10:16:51 AM UTC-5, Daniel wrote:
> const Allocator& alloc,
> const std::filesystem::path& p,
> std::error_code& ec); // (4b)
 
or perhaps
 
directory_iterator(const std::filesystem::path& p,
const Allocator& alloc = Allocator()); // (5a)
 
directory_iterator(std::allocator_arg_t,
const Allocator& alloc,
const std::filesystem::path& p,
std::error_code& ec); // (5b)
 
Thanks,
Daniel
David Brown <david.brown@hesbynett.no>: Mar 03 08:11AM +0100

On 02/03/2020 22:24, Chris M. Thomasson wrote:
 
> Fwiw, the folks over on sci.crypt are telling me that its beyond their
> experience to properly perform crypto analysis on. Perhaps you can help
> tear it apart!?
 
No, I am don't have the knowledge or experience with cryptography to do
an analysis, nor do I have enough maths background (I'm fine with the
workings of RSA, but analysis of hashes and encryptions is beyond me).
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Mar 03 01:31AM -0800

On 3/2/2020 11:11 PM, David Brown wrote:
 
> No, I am don't have the knowledge or experience with cryptography to do
> an analysis, nor do I have enough maths background (I'm fine with the
> workings of RSA, but analysis of hashes and encryptions is beyond me).
 
Damn! If you happen to know any experts, please show this to them, on
your free time. Fwiw, have you tried to run my C code?
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Mar 03 01:33AM -0800

On 3/3/2020 1:31 AM, Chris M. Thomasson wrote:
>> me).
 
> Damn! If you happen to know any experts, please show this to them, on
> your free time. Fwiw, have you tried to run my C code?
 
Its c99, should compile right up using the following sha2 lib:
 
https://github.com/ogay/hmac
 
and allow you to encrypt and decrypt files using a hardcoded secret key
to play with.
woodbrian77@gmail.com: Mar 03 08:06AM -0800

On Monday, March 2, 2020 at 12:15:09 AM UTC-6, red floyd wrote:
 
> Crypto is hard. Really hard. Do not -- repeat DO NOT -- attempt
> to write your own crypto. Use something like OpenSSL, LibreSSL,
> or Guttman's Cryptlib for the crypto and secure channel.
 
 
I'm going to use Wireguard as a first step.
 
 
Brian
Ebenezer Enterprises
https://github.com/Ebenezer-group/onwards
Frederick Gotham <cauldwell.thomas@gmail.com>: Mar 03 07:08AM -0800

I came across this piece of C++ code yesterday for running a separate program on Linux and getting its stdout. It uses "popen" to start the second program, and later uses "pclose" to close the stream.
 
unique_ptr<FILE, decltype(&pclose)> stdout_stream(popen("echo Hello World"),"r"), pclose);
 
I thought it was pretty neat.
Jorgen Grahn <grahn+nntp@snipabacken.se>: Mar 03 03:20PM

On Tue, 2020-03-03, Frederick Gotham wrote:
> stream.
 
> unique_ptr<FILE, decltype(&pclose)> stdout_stream(popen("echo Hello World"),"r"), pclose);
 
> I thought it was pretty neat.
 
It shows what you can do with std::unique_ptr so yes it's kind of
neat. But you lose the ability to check the exit status of the other
process, and that's often not acceptable.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Frederick Gotham <cauldwell.thomas@gmail.com>: Mar 03 07:26AM -0800

On Tuesday, March 3, 2020 at 3:21:06 PM UTC, Jorgen Grahn wrote:
 
> It shows what you can do with std::unique_ptr so yes it's kind of
> neat. But you lose the ability to check the exit status of the other
> process, and that's often not acceptable.
 
 
It's fine in my case as I only need the string (which can be empty if the second program crashes).
 
Code taken from stackoverflow:
 
#include <cstdio> /* In Linux this contains popen, pclose */
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
 
std::string exec(char const *const cmd)
{
std::array<char, 128> buffer;
 
std::string result;
 
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
 
if ( !pipe )
{
throw std::runtime_error("popen() failed!");
}
 
while ( nullptr != fgets(buffer.data(), buffer.size(), pipe.get()) )
{
result += buffer.data();
}
 
return result;
}
cdalten@gmail.com: Mar 03 05:00AM -0800

On Friday, January 31, 2020 at 11:12:35 PM UTC-8, Chris M. Thomasson wrote:
 
> Kim Peek is a wonderful person. He has is issues, but still smart as
> heck! I want him to read a manual. Well, that's mean, but he has the
> ability to remember every damn letter.
 
Saddam Hussein also could remember every letter. I *think*. They said the dude could recite back a 1000 page intelligence report exactly word for word.
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Mar 03 05:15AM -0800

>> heck! I want him to read a manual. Well, that's mean, but he has the
>> ability to remember every damn letter.
 
> Saddam Hussein also could remember every letter. I *think*. They said the dude could recite back a 1000 page intelligence report exactly word for word.
 
Shi% happens man!
fir <profesor.fir@gmail.com>: Mar 02 03:36PM -0800

> per day in comp.programming and comp.programming.threads, so as
> you are noticing you are again not thinking correctly by incorrectly
> thinking this or that.
 
anybody knows except you youre mentally
degraded and by your spamming activity you simply poison and destrou whole groups - which is a crime and you will be punished for it some day and world will be happy
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: