[aspectc-user] Slicing an object created with a template class

Olaf Spinczyk os at aspectc.org
Mon Jun 22 09:54:16 CEST 2009


Hi David,

your second example ...

================================ 
template <class T> TMP {}; 
class Slice
{
TMP<int> vec; //error
}; 
================================

... is syntactically incorrect. To define a class template you need the 
'class' keyword:

template <class T> class TMP {};

I think this explains the error messages in the second example.

In the first example I would first check whether you really included 
<vector> in a.ah. It doesn't look as if this was the case.

Cheers,

Olaf


David Come wrote:
> Hi all.
> I'm still playing with aspect C++ and I've found something weird: i 
> can't slicing an object created with a template class (like a 
> std::vector<int> )
> Have a look:
> ================================
> // a.ah
>
> #ifndef A_AF
> #define A_AF
> class Slice
> {
> int i; //all is fine
> // std::vector<int> vec; //error
> };
>
> aspect Foo
> {
> pointcut what() = "A";
> advice what(): slice Slice; 
> };
>
> #endif
> ================================
> //a.cpp
> class A
> {
> //...
> };
>
> int main()
> {
> return 0;
> }
> ================================
> With this simple code, I've got the following error:
> asp.ah:23: error: cannot declare `std::vector' within `Compte'
> error: "ac++" --config "/tmp/agxx_pcfg1s6c0a" -p. -c "essai2.cpp" -o 
> "/tmp/essai2.cpp_agxx_SliceCMTBo"
>
> And if I try with my own template class like:
> ================================ 
> template <class T> TMP {}; 
> class Slice
> {
> TMP<int> vec; //error
> }; 
> ================================
> I've got:
> asp.ah:22: error: invalid member declaration near token `<'
> asp.ah:22: located in the following non-file unit:
>   private:
>   typedef A Slice;
>
> #line 22 "asp.ah"
>  TMP< int > vec
>
> Does anyone know why ? I know there are some problems with template 
> and aspect C++, but I think it is not this sort of problems.
>
> Thanks. 
> David Côme.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user
>   




More information about the aspectc-user mailing list