Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: help with aurora library  (Read 1405 times)

0 Members and 2 Guests are viewing this topic.

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
help with aurora library
« on: July 31, 2015, 06:40:30 pm »
i tried to use aurora lib just to understand it. however when i compiled the example in its official site i got errors. i don't know why this happened.

the code in official site:
#include <Aurora/Dispatch.hpp>
#include <iostream>

struct Object { virtual ~Object() {} };
struct Asteroid : Object {};
struct Ship : Object {};

void collisionAA(Asteroid*, Asteroid*) { std::cout << "Asteroid-Asteroid\n"; }
void collisionAS(Asteroid*, Ship*)     { std::cout << "Asteroid-Ship\n"; }
void collisionSS(Ship*, Ship*)     { std::cout << "Ship-Ship\n"; }


int main()
{
        // Register "overloaded" functions
        using aurora::Type;
        aurora::DoubleDispatcher<Object*> disp;
        disp.bind(Type<Asteroid>(), Type<Asteroid>(), &collisionAA);
        disp.bind(Type<Asteroid>(), Type<Ship>(), &collisionAS);
        disp.bind(Type<Ship>(), Type<Ship>(), &collisionSS);

        // Call function, given only base class pointers
        Asteroid a;  
        Object* pa = &a;
        Ship s;      
        Object* ps = &s;
        disp.call(pa, ps); // Output: Asteroid-Ship
        std::cin.ignore();
}

errors appear like this:
1>------ Build started: Project: junk_input, Configuration: Debug Win32 ------
1>  Source1.cpp
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\meta\templates.hpp(141): error C2027: use of undefined type 'aurora::detail::FunctionSignature<Signature>'
1>          with
1>          [
1>              Signature=Object *
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\dispatch\doubledispatcher.hpp(126) : see reference to class template instantiation 'aurora::FunctionResult<Signature>' being compiled
1>          with
1>          [
1>              Signature=Object *
1>          ]
1>          c:\users\mohammed\documents\sfml-working\junk_input\junk_input\source1.cpp(17) : see reference to class template instantiation 'aurora::DoubleDispatcher<Object *,aurora::RttiDispatchTraits<Signature,2>>' being compiled
1>          with
1>          [
1>              Signature=Object *
1>          ]
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\meta\templates.hpp(141): error C2146: syntax error : missing ';' before identifier 'Type'
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\meta\templates.hpp(141): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\meta\templates.hpp(141): error C2208: 'aurora::Type' : no members defined using this type
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\meta\templates.hpp(141): fatal error C1903: unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

i'm using VS 2013. how to solve those errors?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: help with aurora library
« Reply #1 on: August 01, 2015, 04:59:49 pm »
This API has changed in the meantime, I just forgot to update the examples :)

Should be good now!
#include <Aurora/Dispatch.hpp>
#include <iostream>

struct Object { virtual ~Object() {} };
struct Asteroid : Object {};
struct Ship : Object {};

void collisionAA(Asteroid*, Asteroid*) { std::cout << "Asteroid-Asteroid\n"; }
void collisionAS(Asteroid*, Ship*)     { std::cout << "Asteroid-Ship\n"; }
void collisionSS(Ship*, Ship*)     { std::cout << "Ship-Ship\n"; }

int main(){
        // Register "overloaded" functions
        using aurora::Type;
        aurora::DoubleDispatcher<void(Object*, Object*)> disp;
        disp.bind(Type<Asteroid>(), Type<Asteroid>(), &collisionAA);
        disp.bind(Type<Asteroid>(), Type<Ship>(), &collisionAS);
        disp.bind(Type<Ship>(), Type<Ship>(), &collisionSS);

        // Call function, given only base class pointers
        Asteroid a;   Object* pa = &a;
        Ship s;       Object* ps = &s;
        disp.call(pa, ps); // Output: Asteroid-Ship
}
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything