Boost logo

Boost Users :

Subject: [Boost-users] RE [date_time] error with g++-4.3.2
From: frederic.bron_at_[hidden]
Date: 2009-01-07 11:15:46




boost-users-bounces_at_[hidden] a écrit sur 07/01/2009 13:37:18 :
>
> In file included from boost/date_time/local_time/tz_database.hpp:14,
> from boost/date_time/local_time/local_time.hpp:19,
> from boost/date_time.hpp:15,
> boost/date_time/tz_db_base.hpp:161: error: declaration of 'typedef
> class boost::date_time::dst_adjustment_offsets<typename
> time_zone_type::time_duration_type>
> boost::date_time::tz_db_base<time_zone_type, rule_type>::
> dst_adjustment_offsets'
> boost/date_time/time_zone_base.hpp:76: error: changes meaning of
> 'dst_adjustment_offsets' from 'class boost::date_time::
> dst_adjustment_offsets<typename time_zone_type::time_duration_type>'

Here is the code that gives an error:

namespace boost { namespace date_time {

template<class time_duration_type> class dst_adjustment_offsets { } ; // in date_time/time_zone_base.hpp

template<class time_zone_type, class rule_type> class tz_db_base { // in date_time/tz_db_base.hpp
      typedef dst_adjustment_offsets<time_duration_type> dst_adjustment_offsets;
} ;

}

I do not understand clearly if this should be allowed (i.e. to give a typedef the same name of a class template) but the standard (2003) says:

7.1.3 The typedef specifier [dcl.typedef]
§2:
In a given non-class scope, a typedef specifier can be used to redefine the name of any type declared in
that scope to refer to the type to which it already refers. [Example:
typedef struct s { /* ... */ } s;
typedef int I;
typedef int I;
typedef I I;
—end example]

but we are in a class scope

§3:
In a given scope, a typedef specifier shall not be used to redefine the name of any type declared in that
scope to refer to a different type. [Example:
class complex { /* ... */ };
typedef int complex; // error: redefinition
—end example] Similarly, in a given scope, a class or enumeration shall not be declared with the same
name as a typedef-name that is declared in that scope and refers to a type other than the class or enumeration
itself. [Example:
typedef int complex;
class complex { /* ... */ }; // error: redefinition
—end example]

are we in the same scope?

F. Bron

Avis :
Ce message et toute pièce jointe sont la propriété d'Alcan et sont destinés seulement aux personnes ou à l'entité à qui le message est adressé. Si vous avez reçu ce message par erreur, veuillez le
détruire et en aviser l'expéditeur par courriel. Si vous n'êtes pas le destinataire du message, vous n'êtes pas autorisé à utiliser, à copier ou à divulguer le contenu du message ou ses pièces jointes
en tout ou en partie.

Notice:
This message and any attachments are the property of Alcan and are intended solely for the named recipients or entity to whom this message is addressed. If you have received this message in error
please inform the sender via e-mail and destroy the message. If you are not the intended recipient you are not allowed to use, copy or disclose the contents or attachments in whole or in part.


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