MSVC++ 2010 and BOOST_STATIC_ASSERT
Hi all! I've noticed that MSVC++ 2010 has implemented static_assert (compile time checks); and probably as a result, the code that used to build fine in MSVC++ 2008 is now generating the following error. code: BOOST_STATIC_ASSERT(N==1) *error C2338: (N==1)* ** Appreciate if anyone who has resolved this error can share their experiences.. Thanks, --Thomas. **
AMDG On 11/01/2011 02:52 PM, Sunil Thomas wrote:
I've noticed that MSVC++ 2010 has implemented static_assert (compile time checks); and probably as a result, the code that used to build fine in MSVC++ 2008 is now generating the following error.
code:
BOOST_STATIC_ASSERT(N==1) *error C2338: (N==1)* **
Appreciate if anyone who has resolved this error can share their experiences..
This code is obviously not complete. The error indicates that N is not 1. You haven't provided any context. In Christ, Steven Watanabe
The condensed code that generates the error in the last e-mail is as
follows:
template<typename T = some_type, std::size_t N=3> my_class {
public:
my_class(const T& i0) {
BOOST_STATIC_ASSERT(N==1);
m_data[0]=i0;
}
private:
T m_data[N];
}
I realize that N defaults to 3 and all, but without making any sweeping
changes, is there a way to force MSVC++ 2010 to just compile, considering
this was compiling fine with MSVC++ 2008?
Thanks,
--Thomas.
On Tue, Nov 1, 2011 at 4:20 PM, Steven Watanabe
AMDG
On 11/01/2011 02:52 PM, Sunil Thomas wrote:
I've noticed that MSVC++ 2010 has implemented static_assert (compile time checks); and probably as a result, the code that used to build fine in MSVC++ 2008 is now generating the following error.
code:
BOOST_STATIC_ASSERT(N==1) *error C2338: (N==1)* **
Appreciate if anyone who has resolved this error can share their experiences..
This code is obviously not complete. The error indicates that N is not 1. You haven't provided any context.
In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi Thomas,
On Tue, Nov 1, 2011 at 11:24 PM, Sunil Thomas
The condensed code that generates the error in the last e-mail is as follows: <snip code> I realize that N defaults to 3 and all, but without making any sweeping changes, is there a way to force MSVC++ 2010 to just compile, considering this was compiling fine with MSVC++ 2008?
Your code (with fairly simple modifications) worked fine for me in
VC10 and g++4.X:
#include
AMDG On 11/01/2011 10:24 PM, Sunil Thomas wrote:
The condensed code that generates the error in the last e-mail is as follows:
template<typename T = some_type, std::size_t N=3> my_class { public: my_class(const T& i0) { BOOST_STATIC_ASSERT(N==1); m_data[0]=i0; } private: T m_data[N]; }
I realize that N defaults to 3 and all, but without making any sweeping changes, is there a way to force MSVC++ 2010 to just compile, considering this was compiling fine with MSVC++ 2008?
The following code compiles fine with MSVC 2010.
#include <cstddef>
#include
Thanks Steve & Nate,
What I am building is a library.. not a main application. My main
application is in unit test libraries. But building the
library itself is generating the error. The class and its implementation is
defined entirely in the header, say, cinc.h
and I forgot to include a typedef after the class definition:
File cinc.h:
----------------------------------------
#include
AMDG
On 11/01/2011 10:24 PM, Sunil Thomas wrote:
The condensed code that generates the error in the last e-mail is as follows:
template<typename T = some_type, std::size_t N=3> my_class { public: my_class(const T& i0) { BOOST_STATIC_ASSERT(N==1); m_data[0]=i0; } private: T m_data[N]; }
I realize that N defaults to 3 and all, but without making any sweeping changes, is there a way to force MSVC++ 2010 to just compile, considering this was compiling fine with MSVC++ 2008?
The following code compiles fine with MSVC 2010.
#include <cstddef> #include
template<class T = int, std::size_t N = 3> class C { public: C() {} C(const T& i0) { BOOST_STATIC_ASSERT(N == 1); m_data[0] = i0; } private: T m_data[N]; };
int main() { C<> c; }
Can you provide a minimal *complete* test case that fails?
In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
AMDG On 11/02/2011 04:32 PM, Sunil Thomas wrote:
Thanks Steve & Nate,
What I am building is a library.. not a main application. My main application is in unit test libraries. But building the library itself is generating the error. The class and its implementation is defined entirely in the header, say, cinc.h and I forgot to include a typedef after the class definition:
<snip>
/cinc.hpp(255) : while compiling class template member function 'void C<>::assign(const unsigned __int64 &)' /cinc.hpp(83): error C2338: N==1*
You've snipped something important. I don't see a definition of assign in your code. Figure out how and why assign is called with 1 argument and that should explain why your code doesn't compile.
I don't see myself doing anything different than what Steve did in his main.. and again, why was this building with MSVC++ 2008 (granted, that N defaults to 3 and all)? Anyways, hope this was more helpful.
In Christ, Steven Watanabe
Thanks Steven,
Didn't mean to snip that out.. I overlooked it as just a warning. So
here is the updated code.
#include
AMDG
On 11/02/2011 04:32 PM, Sunil Thomas wrote:
Thanks Steve & Nate,
What I am building is a library.. not a main application. My main application is in unit test libraries. But building the library itself is generating the error. The class and its implementation is defined entirely in the header, say, cinc.h and I forgot to include a typedef after the class definition:
<snip>
/cinc.hpp(255) : while compiling class template member function 'void C<>::assign(const unsigned __int64 &)' /cinc.hpp(83): error C2338: N==1* You've snipped something important. I don't see a definition of assign in your code. Figure out how and why assign is called with 1 argument and that should explain why your code doesn't compile.
I don't see myself doing anything different than what Steve did in
his
main.. and again, why was this building with MSVC++ 2008 (granted, that N defaults to 3 and all)? Anyways, hope this was more helpful.
In Christ, Steven Watanabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Nathan Crookston
-
Steven Watanabe
-
Sunil Thomas