|
Boost Users : |
From: Fujinobu Takahashi (fjtaka_at_[hidden])
Date: 2005-09-03 08:56:37
Hello Cory-san,
Thank you for your prompt advice for my basic question.
I found same thing happens even when I use dynamic bitsets as member
of struct.
My original simple code:
#include <iostream>
#include <boost/timer.hpp>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using namespace boost;
struct multi_bitsets{
dynamic_bitset<> db1(10,1ul);
dynamic_bitset<> db2(10,2ul);
};
int main()
{
multi_bitsets mb1;
cout<<"mb1.db1:"<<mb1.db1<<endl;
cout<<"mb1.db2:"<<mb1.db2<<endl;
return 0;
}
Long error.log:
$ g++ multi_bitset_struct.org.cpp
multi_bitset_struct.org.cpp:9: error: expected identifier before numeric constant
multi_bitset_struct.org.cpp:9: error: expected `,' or `...' before numeric constant
multi_bitset_struct.org.cpp:9: error: ISO C++ forbids declaration of `parameter' with no type
multi_bitset_struct.org.cpp:10: error: expected identifier before numeric constant
multi_bitset_struct.org.cpp:10: error: expected `,' or `...' before numeric constant
multi_bitset_struct.org.cpp:10: error: ISO C++ forbids declaration of `parameter' with no type
multi_bitset_struct.org.cpp: In function `int main()':
multi_bitset_struct.org.cpp:19: error: no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::cha
r_traits<char> >&)(&std::cout)), ((const char*)"mb1.db1:")) << mb1.multi_bitsets::db1'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/ostream.tcc:63: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits
>::operator<<(std::basic_ostream<_CharT, _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/ostream.tcc:74: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(s
td::basic_ios<_CharT, _Traits>&(*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/ostream.tcc:86: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(s
td::ios_base&(*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
-------------------------------------------------------------------
And modified code with the initializer list suggested by Cory-san:
#include <iostream>
#include <boost/timer.hpp>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using namespace boost;
struct multi_bitsets{
dynamic_bitset<> db1;
dynamic_bitset<> db2;
};
multi_bitsets():db1(10,1ul), db2(10,2ul){}
int main()
{
multi_bitsets mb1;
cout<<"mb1.db1:"<<mb1.db1<<endl;
cout<<"mb1.db2:"<<mb1.db2<<endl;
return 0;
}
Very simple error code:
$ g++ multi_bitset_struct.cpp
multi_bitset_struct.cpp:14: error: expected unqualified-id before ')' token
multi_bitset_struct.cpp:14: error: expected `,' or `;' before ':' token
I am very helpful to gett any comments or solution for the error.
Very thanks,
Fuji
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net