Re: Fwd: Re: [sigc] [Fwd: libsigc++ 1.9.13 fails on Solaris 9 sparc] [martin-ml hippogriff de]



Am 2004.02.20 19:08 schrieb(en) Damien Carbery:
Looks like similar issues as last time. Log attached.

That's bad news. Could you just try to compile the test program
I'm attaching and e-mail me the output of the binary? We need to
find a working flavour of is_base_and_derived<>!
I did some research and obviously boost are using the same sizeof()
trick than us. There doesn't seem to be an alternative.

I had trouble applying the patch - I'm not very good at that.

Sorry for that.

 patch -p0 < ../base_and_derived.patch

works for me in directory libsigc++-1.9.14.

Regards,

 Martin


I tried
  cd libsigc++-1.9.14
  patch -l -N < base
and
  cd libsigc++-1.9.14
  patch -l -N -p1 < base
but neither time could the files to be patches be found.
Running the same commands from one dir up didn't make any difference.
I ended up carefully applying the changes manually.

Damien.

Martin Schulze wrote:
Here comes the attachment ...

Am 2004.02.19 09:56 schrieb(en) Damien Carbery:

All,

In the first build I did last week I used a tarball from sourceforge. The site was available about an hour after Murrary asked for help.

I downloaded the latest tarball (1.9.14) and attempted to build it on Solaris 9 Update 4 sparc. The attached log shows my environment, configure output and make output.


Thanks a lot!

The errors start with:
"../sigc++/adaptors/lambda/base.h", line 174: Error: Could not find sigc::internal::lambda_core<sigc::internal::lambda_select7, 0>:: lambda_core() to initialize base class.


The wrong template specialization is used because
sigc::is_base_and_derived<> yields a wrong result. Hopefully the reason
is that sizeof(char)==sizeof(double) on your platform. I committed a
patch to cvs that would fix this once and for all. I'm attaching the
patch to this email.

Damien, could you please apply this patch to your copy of libsigc++ 1.9.14 and try again?

Regards,

Martin

/*
 * Copyright 2002, The libsigc++ Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#include <iostream>
 

template <class T_type>
struct type_trait
{
  typedef T_type  type;
  typedef T_type& pass;
  typedef const T_type& take;
  typedef T_type* pointer;
  static  T_type  instance(); /* not implemented */  
};

template <class T_type, int N>
struct type_trait<T_type[N]>
{
  typedef T_type*  type;
  typedef T_type*& pass;
  typedef const T_type*& take;
  typedef T_type** pointer;
  static  T_type*  instance(); /* not implemented */  
};

template <class T_type>
struct type_trait<T_type&>
{
  typedef T_type  type;
  typedef T_type& pass;
  typedef T_type& take;
  typedef T_type* pointer;
  static  T_type& instance(); /* not implemented */ 
};

template <class T_type>
struct type_trait<const T_type&>
{
  typedef const T_type  type;
  typedef const T_type& pass;
  typedef const T_type& take;
  typedef const T_type* pointer;
  static  const T_type& instance(); /* not implemented */ 
};

/*template <class T_type>
struct type_trait<reference_wrapper<T_type> >
{
  typedef T_type  type;
  typedef T_type& pass;
  typedef T_type& take;
  typedef T_type* pointer;
  static  T_type& instance();
};

template <class T_type>
struct type_trait<const_reference_wrapper<T_type> >
{
  typedef T_type  type;
  typedef T_type& pass;
  typedef const T_type& take;
  typedef T_type* pointer;
  static  T_type& instance();
};*/

template<>
struct type_trait<void>
{
  typedef void  type;
  typedef void  pass;
  typedef void  take;
  typedef void* pointer;
  static  void  instance(); /* not implemented */
};


/** From Esa Pulkkin:
 * Compile-time determination of base-class relationship in C++
 * (adapted to match the syntax of boost's type_traits library).
 */
 
/* doesn't seem to work with the SUN Forte: */
template <class T_base, class T_derived>
struct is_base_and_derived
{
/*private:*/
  struct big {
    char memory[64];
  };

  struct test {
    static big  is_base_class_(const void*);
    static char is_base_class_(typename type_trait<T_base>::pointer);
  };

/*public:*/
  static const bool value =
    sizeof(test::is_base_class_((typename type_trait<T_derived>::pointer)0)) ==
    sizeof(char);
};

template <class T_base>
struct is_base_and_derived<T_base, T_base>
{
  static const bool value = true;
};


/* test 1: */
template <class T_base, class T_derived>
struct is_base_and_derived1
{
/*private:*/
  struct big {
    char memory[64];
  };

  struct test {
    static big  is_base_class_(void*);
    static char is_base_class_(typename type_trait<T_base>::pointer);
  };

/*public:*/
  static const bool value =
    sizeof(test::is_base_class_((typename type_trait<T_derived>::pointer)0)) ==
    sizeof(char);
};

template <class T_base>
struct is_base_and_derived1<T_base, T_base>
{
  static const bool value = true;
};


/* test 2: */
template <class T_base, class T_derived>
struct is_base_and_derived2
{
/*private:*/
  struct big {
    char memory[64];
  };

  struct test {
    static big  is_base_class_(...);
    static char is_base_class_(typename type_trait<T_base>::pointer);
  };

/*public:*/
  static const bool value =
    sizeof(test::is_base_class_((typename type_trait<T_derived>::pointer)0)) ==
    sizeof(char);
};

template <class T_base>
struct is_base_and_derived2<T_base, T_base>
{
  static const bool value = true;
};


/* test 3: */
template <class T_base, class T_derived>
struct is_base_and_derived3
{
/*private:*/
  struct big {
    char memory[64];
  };

  struct test {
    static big  is_base_class_(...);
    static char is_base_class_(typename type_trait<T_base>::pointer);
  };

  static typename type_trait<T_derived>::pointer derived;

/*public:*/
  static const bool value =
    sizeof(test::is_base_class_(derived)) ==
    sizeof(char);
};

template <class T_base>
struct is_base_and_derived3<T_base, T_base>
{
  static const bool value = true;
};



struct A {};
struct B : A {};
struct C {};
struct D : B {};
template <class T_type, bool I_islambda = is_base_and_derived<A, T_type>::value> struct A_test;
template <class T_type> struct A_test<T_type, false> { static const bool value=false; };
template <class T_type> struct A_test<T_type, true>  { static const bool value=true; };
template <class T_type, bool I_islambda = is_base_and_derived1<A, T_type>::value> struct A_test1;
template <class T_type> struct A_test1<T_type, false> { static const bool value=false; };
template <class T_type> struct A_test1<T_type, true>  { static const bool value=true; };
template <class T_type, bool I_islambda = is_base_and_derived2<A, T_type>::value> struct A_test2;
template <class T_type> struct A_test2<T_type, false> { static const bool value=false; };
template <class T_type> struct A_test2<T_type, true>  { static const bool value=true; };
template <class T_type, bool I_islambda = is_base_and_derived3<A, T_type>::value> struct A_test3;
template <class T_type> struct A_test3<T_type, false> { static const bool value=false; };
template <class T_type> struct A_test3<T_type, true>  { static const bool value=true; };

int main() {
  std::cout << "is_base_and_derived test ..." << std::endl;

  std::cout << "sizeof(char): " << sizeof(char) << std::endl;
  std::cout << "sizeof(is_base_and_derived<A,B>::big): " << sizeof(is_base_and_derived<A,B>::big) << std::endl;

  std::cout << "is_base_and_derived<A,A>: " << is_base_and_derived<A,A>::value << std::endl;
  std::cout << "is_base_and_derived<A,B>: " << is_base_and_derived<A,B>::value << std::endl;
  std::cout << "is_base_and_derived<A,C>: " << is_base_and_derived<A,C>::value << std::endl;
  std::cout << "is_base_and_derived<A,D>: " << is_base_and_derived<A,D>::value << std::endl;
  std::cout << "A_test<A>: " << A_test<A>::value << std::endl;
  std::cout << "A_test<B>: " << A_test<B>::value << std::endl;
  std::cout << "A_test<C>: " << A_test<C>::value << std::endl;
  std::cout << "A_test<D>: " << A_test<D>::value << std::endl;

  std::cout << "is_base_and_derived1<A,A>: " << is_base_and_derived1<A,A>::value << std::endl;
  std::cout << "is_base_and_derived1<A,B>: " << is_base_and_derived1<A,B>::value << std::endl;
  std::cout << "is_base_and_derived1<A,C>: " << is_base_and_derived1<A,C>::value << std::endl;
  std::cout << "is_base_and_derived1<A,D>: " << is_base_and_derived1<A,D>::value << std::endl;
  std::cout << "A_test1<A>: " << A_test1<A>::value << std::endl;
  std::cout << "A_test1<B>: " << A_test1<B>::value << std::endl;
  std::cout << "A_test1<C>: " << A_test1<C>::value << std::endl;
  std::cout << "A_test1<D>: " << A_test1<D>::value << std::endl;

  std::cout << "is_base_and_derived2<A,A>: " << is_base_and_derived2<A,A>::value << std::endl;
  std::cout << "is_base_and_derived2<A,B>: " << is_base_and_derived2<A,B>::value << std::endl;
  std::cout << "is_base_and_derived2<A,C>: " << is_base_and_derived2<A,C>::value << std::endl;
  std::cout << "is_base_and_derived2<A,D>: " << is_base_and_derived2<A,D>::value << std::endl;
  std::cout << "A_test2<A>: " << A_test2<A>::value << std::endl;
  std::cout << "A_test2<B>: " << A_test2<B>::value << std::endl;
  std::cout << "A_test2<C>: " << A_test2<C>::value << std::endl;
  std::cout << "A_test2<D>: " << A_test2<D>::value << std::endl;

  std::cout << "is_base_and_derived3<A,A>: " << is_base_and_derived3<A,A>::value << std::endl;
  std::cout << "is_base_and_derived3<A,B>: " << is_base_and_derived3<A,B>::value << std::endl;
  std::cout << "is_base_and_derived3<A,C>: " << is_base_and_derived3<A,C>::value << std::endl;
  std::cout << "is_base_and_derived3<A,D>: " << is_base_and_derived3<A,D>::value << std::endl;
  std::cout << "A_test3<A>: " << A_test3<A>::value << std::endl;
  std::cout << "A_test3<B>: " << A_test3<B>::value << std::endl;
  std::cout << "A_test3<C>: " << A_test3<C>::value << std::endl;
  std::cout << "A_test3<D>: " << A_test3<D>::value << std::endl;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]