"Ralf W. Grosse-Kunstleve" <[EMAIL PROTECTED]> writes: > Below is a stand-alone minimal test that still produces the same error message > with MIPSpro: > > % CC -LANG:std zminmin.cpp > cc-1108 CC: ERROR File = zminmin.cpp, Line = 13 > The indicated expression must have pointer-to-function type. > > static const unsigned long value = sizeof(bdhelper_t::check()); > ^ > > 1 error detected in the compilation of "zminmin.cpp". > > The same code works correctly with gcc 2.96 and an EDG245-based compiler > (Compaq cxx). However, here is an interesting observation: > > % cxx -std strict_ansi zminmin.cpp > % a.out > 4 > > No problem with "strict_ansi." But: > > % cxx -std ansi -D__USE_STD_IOSTREAM zminmin.cpp > cxx: Error: zminmin.cpp, line 13: operand of sizeof may not be a function > static const unsigned long value = sizeof(bdhelper_t::check()); > ----------------------------------------------^ > cxx: Info: 1 error detected in the compilation of "zminmin.cpp". > > I am jumping to the conclusion that older EDG's don't support > sizeof(some_function()). Does that sound plausible?
Not to me; this technique is used all over the Boost type traits. Nothing would've ever worked with this compiler if that were true, pretty much. > What could be done to make the is_base_and_derived test work with > MIPSpro? Is the test actually used in Boost.Python? Yes. > -- I noticed that MIPSpro chokes even if is_base_and_derived_impl2 > is not instantiated. > > Thanks! > Ralf There are any number of ways you could try reformulating this to make the error go away. At worst you could try the __BORLANDC__ branch in is_base_and_derived.hpp. Another approach: template <typename B, typename D, typename T> static type_traits::yes_type bd_helper(D const volatile *, T); template <typename B, typename D> static type_traits::no_type bd_helper(B const volatile *, int); template<typename B, typename D> struct is_base_and_derived_impl2 { struct Host { operator B const volatile *() const; operator D const volatile *(); }; BOOST_STATIC_CONSTANT(bool, value = sizeof(bd_helper<B,D>(Host(), 0)) == sizeof(type_traits::yes_type)); }; > > #include <iostream> > > template <typename B, typename D> > struct bd_helper > { > static int check(); > }; > > template<typename B, typename D> > struct is_base_and_derived_impl2 > { > typedef bd_helper<B,D> bdhelper_t; > static const unsigned long value = sizeof(bdhelper_t::check()); > }; > > int main() > { > unsigned long n = is_base_and_derived_impl2<int, float>::value; > std::cout << n << std::endl; > } > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Tax Center - forms, calculators, tips, more > http://taxes.yahoo.com/ > _______________________________________________ > Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost -- Dave Abrahams Boost Consulting www.boost-consulting.com _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost