D
David Jobet
Hello,
I'm trying to compile a small example extracted from here :
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html#ImplFlag
I compile it with gcc 4.4.3 using the following command line :
g++ --std=c++0x test.cpp
And I get the following error :
test.cpp: In function ‘int main(int, char**)’:
test.cpp:24: error: no matching function for call to
‘atomic_flag::atomic_flag(<brace-enclosed initializer list>)’
test.cpp:13: note: candidates are: atomic_flag::atomic_flag(const
atomic_flag&)
test.cpp:12: note: atomic_flag::atomic_flag()
I'm quite new to c++0x, I know it is not finalized, but still, if the draft
says that "The macro ATOMIC_FLAG_INIT shall be deï¬ned in such a way that it
can be used to initialize an object of
type atomic_flag to the clear state."
I guess this should be possible to do it without having to change the
interface right ?
So, my question is the following : does gcc has a problem here or this is
the code which is actually incorrect ?
If the code is actually incorrect (which I would tend to believe) how can
one implement this macro without changing the interface of the struct
atomic_flag ? (for example, by adding the explicit initialize_list
constructor atomic_flag(std::initializer_list<bool> list))
Tx for the help
David
PS : This is the extract
---
enum memory_order
{
memory_order_seq_cst // should have more members, but this is enough to
compile the example
};
typedef struct atomic_flag
{
bool test_and_set( memory_order = memory_order_seq_cst ) volatile;
void clear( memory_order = memory_order_seq_cst ) volatile;
void fence( memory_order ) const volatile;
atomic_flag() = default;
atomic_flag( const atomic_flag& ) = delete;
atomic_flag& operator =( const atomic_flag& ) = delete;
private:
bool __f__;
} atomic_flag;
#define ATOMIC_FLAG_INIT { false }
int main(int argc, char **argv)
{
atomic_flag af = ATOMIC_FLAG_INIT;
return 0;
}
I'm trying to compile a small example extracted from here :
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html#ImplFlag
I compile it with gcc 4.4.3 using the following command line :
g++ --std=c++0x test.cpp
And I get the following error :
test.cpp: In function ‘int main(int, char**)’:
test.cpp:24: error: no matching function for call to
‘atomic_flag::atomic_flag(<brace-enclosed initializer list>)’
test.cpp:13: note: candidates are: atomic_flag::atomic_flag(const
atomic_flag&)
test.cpp:12: note: atomic_flag::atomic_flag()
I'm quite new to c++0x, I know it is not finalized, but still, if the draft
says that "The macro ATOMIC_FLAG_INIT shall be deï¬ned in such a way that it
can be used to initialize an object of
type atomic_flag to the clear state."
I guess this should be possible to do it without having to change the
interface right ?
So, my question is the following : does gcc has a problem here or this is
the code which is actually incorrect ?
If the code is actually incorrect (which I would tend to believe) how can
one implement this macro without changing the interface of the struct
atomic_flag ? (for example, by adding the explicit initialize_list
constructor atomic_flag(std::initializer_list<bool> list))
Tx for the help
David
PS : This is the extract
---
enum memory_order
{
memory_order_seq_cst // should have more members, but this is enough to
compile the example
};
typedef struct atomic_flag
{
bool test_and_set( memory_order = memory_order_seq_cst ) volatile;
void clear( memory_order = memory_order_seq_cst ) volatile;
void fence( memory_order ) const volatile;
atomic_flag() = default;
atomic_flag( const atomic_flag& ) = delete;
atomic_flag& operator =( const atomic_flag& ) = delete;
private:
bool __f__;
} atomic_flag;
#define ATOMIC_FLAG_INIT { false }
int main(int argc, char **argv)
{
atomic_flag af = ATOMIC_FLAG_INIT;
return 0;
}