« first day (1844 days earlier)      last day (1014 days later) » 

12:48 AM
/>>Mgetz, if you need to suspend you should use something that has good management characteristics
By condition_variable?
 
1:26 AM
if you actually sleep you are then at the mercy of the scheduler which can be set to a fairly high granularity depending on the system
if yuou are waiting on another core then actual busy loop is fine if you expect it to trigger soon
 
2:05 AM
Does boost::atomic<bool> flag{}; guarantee flag to be false?
 
 
5 hours later…
mr5
C++ is so hard Y_Y
 
7:14 AM
Er, I used to think the default value for boost::atomic<T> val{}; is T().
 
8:09 AM
What's std::vector<int> v{100, std::reserve_tag};?
 
8:26 AM
@John that doesn't exist
it's basically a suggestion to try and be able to disambiguate creating a vector<int> with

* only 1 element with the value 100
* 100 ints being value initialized
* 0 elements but reserving space for 100 elements
 
9:21 AM
If I have a file with some const values and two folders(one for client, one for server), I want to use these values from client and from server, is there a better solution than duplicating the same file and comparing via cmake whether the content of the two files are the same? Does git have a tool for solving this problem?
 
@SKIP just reuse one header file
add and include folder and add it to the include search path of both projects
you can symlink the same file into both folders, git doesn't have a problem with symlinks.

But in my opinion it's best to keep git repos free of links
 
@PeterT How can I name the folder to make it clear for people that it's a common folder for client and server?
 
"include", "common", "base", "core" or even "config" whatever you think fits best
 
9:37 AM
Thanks
 
9:56 AM
@John I see, thank you.
 
 
1 hour later…
11:11 AM
@PeterT Still about boost::atomic<bool> , I repeatedly run this program(here is the source code) on Ubuntu . I am surprised that boost::atomic<bool> second{} is always false whereas boost::atomic<bool> third; could be either false or true.
 
11:33 AM
Here are the commands which I used to do the test:
`while [ true ]; do ./test_aomic_value_program | grep third ; done` #most outputs false, randomly true;
while [ true ]; do ./test_aomic_value_program | grep second | grep true; done #nothing outputs indeed!
 
11:48 AM
Since they both call the default constructor of boost::atomic<T>, I think they should have the same behaviour. But they does not indeed.
 
well it does say unspecified which can include uninitialized
and if you have it on the stack and some previous function calls leave that spot in the stack with the same values every time, then it can "seem" like it's always the same
 
12:05 PM
>well it does say unspecified which can include uninitialized
I have no doubt about it.

They(i.e `boost::atomic<bool> second{};` and `boost::atomic<bool> third;`) both call the `boost::atomic<T>()` other than `boost::atomic<T>(T initial_value)`, am I right?
 
they should, you can swap their order and see if that makes a difference
 
12:39 PM
I swap their order and no difference indeed.
Since they both call the `boost::atomic<T>()`, I think they should have the same behaviour. But they does not indeed. That's what confuses me.
 
any reason you're using boost atomic and not std atomic?
AFAIK the latter should be pretty wide spread at this point
 
mr5
By any chance, are you the author of stack crooked online compiler @PeterT?
 
LUL no, that's @StackedCrooked
 
mr5
oh
 
Mgetz, because the project was written by another persion other than by myself. I just maintain it.
 
mr5
12:43 PM
I only remember the avatar image
looks similar to yours
 
well he has a luffy avatar, mine's some dude from scott pilgrim
 
Mgetz, PeterT And I carefully read the implementation of boost::atomic<T>, which makes me have more confident that they (i.e boost::atomic<bool> second{}; and boost::atomic<bool> third;) should have the same behaviour.
see line 90
on https://code.woboq.org/boost/boost/boost/atomic/detail/atomic_template.hpp.html
 
mr5
almost 2 months have passed and I am still stuck on this websocket task I have
 
oh, the default constructor is not user-provided? I think that means that {} will zero-initialize the members
whereas a call to the constructor will default initialize them
 
> oh, the default constructor is not user-provided?

I did not get your idea.
 
12:57 PM
struct MyType{MyType(){}}; //user-provided

struct MyType{MyType() =default;}; //not user-provided, defaulted as if it was compiler-generated
 
The default ctor for `boost::atomic` is :
`boost::atomic<T>(){}` and nothing more.
It's nothing special.
 
maybe you look at 93 again and see what the macro does
I assume you're not compiling with a C++98 compiler
 
I really read it, perhaps I miss something. I read it again now.
 
the fact that it zero-initializes is not something you should rely on anyways
 
I really read it, perhaps I miss something. I read it again now.
 
1:08 PM
the documentation/specification says it's unspecified and you should treat it like that
any version it would be allowed to change that behavior
 
BOOST_DEFAULTED_FUNCTION(base_atomic(), {})

expands liks this:

#if !(defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS))
# define BOOST_DEFAULTED_FUNCTION(fun, body) fun = default;
#else
# define BOOST_DEFAULTED_FUNCTION(fun, body) fun body
#endif

Since C++11 is enabled, so it should be the latter one:
BOOST_DEFAULTED_FUNCTION(base_atomic(), {}) --> base_atomic(){}
 
it should be the first one
the macros read
BOOST_********NO*********_CXX11_DEFAULTED_FUNCTIONS
 
Yes, the first one.
BOOST_DEFAULTED_FUNCTION(base_atomic(), {}) --> base_atomic() = default
PeterT, base_atomic() = default has relation to boost::atomic<bool> second{} are always to be false?
PeterT, base_atomic() = default causes boost::atomic<bool> second{} always to be false?
 
1:30 PM
yes, that is what https://en.cppreference.com/w/cpp/language/value_initialization says

> if T is a class type with a default constructor that is neither user-provided nor deleted (that is, it may be a class with an implicitly-defined or defaulted default constructor), the object is zero-initialized and then it is default-initialized if it has a non-trivial default constructor;
 
Then, why boost::atomic<bool> third; could be either false or true.
 
because it's not zero-initializing the members before default-initializing them
 
1:51 PM
You mean boost::atomic<bool> second{} firstly zeros the member variable and then calls the default ctor whereas boost::atomic<bool> third directly calls the default ctor?
 
it only calls the default ctor of the data members if they have a non-trivial default ctor, otherwise it just zero-initializes them
 
>it only calls the default ctor of the data members if they have a non-trivial default ctor, otherwise it just zero-initializes them
Sorry, I still can't catch up.
 
just read what the quote from cppreference says
 
I will read it again.
 

« first day (1844 days earlier)      last day (1014 days later) »