boost::function



  • Vielleicht dasselbe nochmal mit dem Visual C++ Compiler? 🙄



  • obs*g* naja ich glaub kaum das der vc compiler ne andere nummer hat;)
    ruf mal cl onder nmake auf...
    cu



  • @LordJaxom: kar, aber wie heißt der?

    Greetz, Swordfish



  • C:\Programme\Microsoft Visual Studio 8\VC\bin>nmake
    
    Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    NMAKE : fatal error U1064: MAKEFILE not found and no target specified
    Stop.
    

    oder?



  • fu*k:

    Microsoft (R) Program Maintenance Utility, Version 7.00.9466
    

    Damit hat sich das Thema mit boost::function wohl erledigt. Kann mir jemand verraten, ob man in ein MSVS 2002 .net einen späteren Compiler einbinden kann?

    Greetz, Swordfish



  • hast du boost mit "-sTOOLS=vc-7_0" compiliert?

    cu



  • Ne, aber jetzt compilier ich 'grad mit "-sTOOLS=vc7".

    Greetz, Swordfish



  • und gehts besser?



  • Hallo,

    Mircosoftprodukte machen nur ärger :D.

    MFG winexec*



  • winexec* schrieb:

    Hallo,

    Mircosoftprodukte machen nur ärger :D.

    MFG winexec*

    Nur wenn man nicht weiß wie man damit umgeht. Und das gilt nicht nur für Microsoft Programme.

    Für mich sieht es einfach so aus als hätte da jemand unteranderem die Include Verzeichnisse falsch gesetzt (edit: Oder überhaupt nicht) und http://www.boost.org/more/getting_started.html nicht gelesen.

    BR
    Vinzenz



  • #include <iostream>
    #include <boost/lambda/lambda.hpp>
    #include <boost/function.hpp>
    #include <boost/bind.hpp>
    
    struct add
    {
    	float operator()(float x, float y) const
    	{
    		return x + y;
    	}
    };
    
    #define PRINT(expr) std::cout << "\t" #expr ": " << (expr) << std::endl;
    
    typedef boost::function<float(float,float)> function2d_t;
    typedef boost::function<float(float)> function1d_t;
    
    int main()
    {
    	using namespace boost;
    	namespace bl = boost::lambda; // use boost lambda to define unnamed functions
    	std::cout << "Adder example f(x,y) = x+y -> g(y) = 10+y" << std::endl;
    	function2d_t f = add(); // f(x,y) = x+y
    	function1d_t g = bind(f,10,_1); // g(y) = 10+y;
    
    	PRINT(f(10,20));
    	PRINT(g(20));
    
    	// classical division example using lambda functions
    	function2d_t div = bl::_1 / bl::_2;
    	function1d_t div_by_4 = bind(div,_1,4.0);
    
    	std::cout << "Division example div(x,y) : x/y" << std::endl;
    	PRINT(div(2,4));
    	PRINT(div_by_4(2));
    }
    

    wie funktioniert das denn? hmm...hat jemand ein besseres beispiel woran man erkennen kann wie boost::function mit boost::bind arbeiten?



  • vielleicht steh ich gerade wieder mal auf dem Schlauch, aber wo ist der Unterschied von

    ... 
    
        boost::function< int( int a ) > f; 
    
        if( a < 10 ) { 
    
            f = foo; 
    
        } else { 
    
            f = bar; 
        } 
    
        std::cout << f( a ) << std::endl;
    

    und

    if( a < 10)
        std::cout << foo(a) << std::endl;
    else
        std::cout << bar(a) << std::endl;
    

    Ich sehe da den Vorteil der Boost::function nicht...

    Gruß Paddy



  • Du stehst auf dem Schlauch. Das sind nur Beispiele, wie man es dynamisch machen kann. Was wäre zum Beispiel, wenn du kein std::endl sondern "asdf\n" anfügen wolltest? Nun stell dir das mal in einem großen switch vor, das gibt Spaß ;).
    Die eigentliche Verwendung von Funktionsobjekten sind aber mehr solche Sachen wie Callbacks.



  • Danke,

    Das mit den Callbacks, bzw. Zeigern auf Methoden, bzw. "generische Zeiger auf Methoden" war mir klar. Ich hatte lediglich den Vorteil in diesem Beispiel nicht gesehen...



  • evilissimo schrieb:

    winexec* schrieb:

    Hallo,

    Mircosoftprodukte machen nur ärger :D.

    MFG winexec*

    Nur wenn man nicht weiß wie man damit umgeht. Und das gilt nicht nur für Microsoft Programme.

    War das jetzt (auch) auf mich bezogen? 😡

    evilissimo schrieb:

    Für mich sieht es einfach so aus als hätte da jemand unteranderem die Include Verzeichnisse falsch gesetzt (edit: Oder überhaupt nicht) und http://www.boost.org/more/getting_started.html nicht gelesen.

    Doch, hab' ich (natürlich!). Bei einer Installation wie

    tree C:\programme\boost\include /a schrieb:

    C:\PROGRAMME\BOOST\INCLUDE
    \---boost-1_33_1
        \---boost
            +---algorithm
            |   \---string
            |       +---detail
            |       \---std
            +---archive
            |   +---detail
            |   +---impl
            |   \---iterators
            +---assign
            |   \---std
            +---bind
            +---compatibility
            |   \---cpp_c_headers
            +---config
            |   +---abi
            |   +---compiler
            |   +---platform
            |   \---stdlib
            +---date_time
            |   +---gregorian
            |   +---local_time
            |   \---posix_time
            +---detail
            +---dynamic_bitset
            +---filesystem
            +---format
            |   \---detail
            +---function
            |   \---detail
            +---functional
            |   +---detail
            |   \---hash
            +---graph
            |   \---detail
            +---integer
            +---io
            +---iostreams
            |   +---detail
            |   |   +---adapter
            |   |   +---broken_overload_resolution
            |   |   +---config
            |   |   +---streambuf
            |   |   \---vc6
            |   +---device
            |   \---filter
            +---iterator
            |   \---detail
            +---lambda
            |   \---detail
            +---logic
            +---math
            |   \---special_functions
            +---mpl
            |   +---aux_
            |   |   +---config
            |   |   +---preprocessed
            |   |   |   +---bcc
            |   |   |   +---bcc551
            |   |   |   +---dmc
            |   |   |   +---gcc
            |   |   |   +---msvc60
            |   |   |   +---msvc70
            |   |   |   +---mwcw
            |   |   |   +---no_ctps
            |   |   |   +---no_ttp
            |   |   |   \---plain
            |   |   +---preprocessor
            |   |   +---range_c
            |   |   \---test
            |   +---limits
            |   +---list
            |   |   \---aux_
            |   |       \---preprocessed
            |   |           \---plain
            |   +---map
            |   |   \---aux_
            |   |       \---preprocessed
            |   |           +---no_ctps
            |   |           +---plain
            |   |           \---typeof_based
            |   +---math
            |   +---multiset
            |   |   \---aux_
            |   +---set
            |   |   \---aux_
            |   |       \---preprocessed
            |   |           \---plain
            |   \---vector
            |       \---aux_
            |           \---preprocessed
            |               +---no_ctps
            |               +---plain
            |               \---typeof_based
            +---multi_array
            +---multi_index
            |   \---detail
            +---numeric
            |   +---conversion
            |   |   \---detail
            |   +---interval
            |   |   +---compare
            |   |   +---detail
            |   |   \---ext
            |   \---ublas
            |       \---detail
            +---optional
            +---parameter
            |   \---aux_
            +---pending
            |   \---detail
            +---pool
            |   \---detail
            +---preprocessor
            |   +---arithmetic
            |   |   \---detail
            |   +---array
            |   +---comparison
            |   +---config
            |   +---control
            |   |   \---detail
            |   |       +---dmc
            |   |       +---edg
            |   |       \---msvc
            |   +---debug
            |   +---detail
            |   |   \---dmc
            |   +---facilities
            |   +---iteration
            |   |   \---detail
            |   |       +---bounds
            |   |       \---iter
            |   +---list
            |   |   \---detail
            |   |       +---dmc
            |   |       \---edg
            |   +---logical
            |   +---punctuation
            |   +---repetition
            |   |   \---detail
            |   |       +---dmc
            |   |       +---edg
            |   |       \---msvc
            |   +---selection
            |   +---seq
            |   |   \---detail
            |   +---slot
            |   |   \---detail
            |   \---tuple
            +---program_options
            |   \---detail
            +---ptr_container
            |   \---detail
            +---python
            |   +---converter
            |   +---detail
            |   +---object
            |   \---suite
            |       \---indexing
            |           \---detail
            +---random
            |   \---detail
            +---range
            |   \---detail
            |       +---mfc
            |       \---vc6
            +---regex
            |   +---config
            |   +---pending
            |   \---v4
            +---serialization
            |   \---detail
            +---signals
            |   \---detail
            +---spirit
            |   +---actor
            |   +---attribute
            |   +---core
            |   |   +---composite
            |   |   |   \---impl
            |   |   +---impl
            |   |   +---non_terminal
            |   |   |   \---impl
            |   |   +---primitives
            |   |   |   \---impl
            |   |   \---scanner
            |   |       \---impl
            |   +---debug
            |   |   \---impl
            |   +---dynamic
            |   |   \---impl
            |   +---error_handling
            |   |   \---impl
            |   +---fusion
            |   |   +---algorithm
            |   |   |   \---detail
            |   |   +---detail
            |   |   +---iterator
            |   |   |   \---detail
            |   |   |       +---cons_iterator
            |   |   |       +---filter_view_iterator
            |   |   |       +---joint_view_iterator
            |   |   |       +---single_view_iterator
            |   |   |       +---transform_view_iterator
            |   |   |       +---tuple_iterator
            |   |   |       \---type_sequence_iterator
            |   |   \---sequence
            |   |       \---detail
            |   +---iterator
            |   |   \---impl
            |   +---meta
            |   |   \---impl
            |   +---phoenix
            |   +---symbols
            |   |   \---impl
            |   +---tree
            |   |   \---impl
            |   \---utility
            |       \---impl
            |           \---chset
            +---test
            |   +---detail
            |   +---impl
            |   +---included
            |   +---output
            |   \---utils
            |       +---basic_cstring
            |       +---iterator
            |       \---runtime
            |           +---cla
            |           |   +---detail
            |           |   \---iface
            |           +---env
            |           \---file
            +---thread
            |   \---detail
            +---tuple
            |   \---detail
            +---type_traits
            |   \---detail
            +---utility
            |   \---detail
            +---variant
            |   \---detail
            \---wave
                +---cpplexer
                |   \---re2clex
                +---grammars
                \---util
    

    und dem 'lib' Verzeichnis in C:\Programme\boost\lib\ ist ein
    Include Path von C:\Programme\Boost\include\boost-1_33_1\ und ein Lib Path von C:\Programme\Boost\lib wohl korrekt, oder?!

    Greetz, Swordfish



  • Das galt winexec weil er meint das MS Produkte nur ärger machen.

    Naja wenn du erst im nachhinein sagst, dass du das kompilierst dann frag ich mich ob du das vorher auch schon gesetzt hattest. Wie auch immer die Pfade sollten richtig sein.

    BR
    Vinzenz



  • Preferred syntax
    * GNU C++ 2.95.x, 3.0.x, 3.1.x
    * Comeau C++ 4.2.45.2
    * SGI MIPSpro 7.3.0
    * Intel C++ 5.0, 6.0
    * Compaq's cxx 6.2
    * Microsoft Visual C++ 7.1

    Portable syntax
    * Any compiler supporting the preferred syntax
    * Microsoft Visual C++ 6.0, 7.0
    * Borland C++ 5.5.1
    * Sun WorkShop 6 update 2 C++ 5.3
    * Metrowerks CodeWarrior 8.1

    Preferred syntax 
    boost::function<float (int x, int y)> f;
    
    Portable syntax
    boost::function2<float, int, int> f;
    

    💡



  • evilissimo schrieb:

    Naja wenn du erst im nachhinein sagst, dass du das kompilierst dann frag ich mich ob du das vorher auch schon gesetzt hattest. Wie auch immer die Pfade sollten richtig sein.

    Ich hatte boost natürlich vorher auch schon Compiliert und die Pfade gesetzt, da jedoch mit einem "-sTOOLS=vc7_1". Desswegen hielt ich es für angebracht, neu zu compilieren mit der korrekten angabe des Toolsets.

    @1310-Logik: Ja, das hab' ich vorher auch gelesen, war jedoch der Meinung, ich hätt' einen VC 7.1. ➡ falsch gemeint.

    @all: Entschuldigt, dass ich aufgrund meiner Fehlannahme eure Zeit verschwendet habe 😞

    Greetz, Swordfish



  • Swordfish schrieb:

    @all: Entschuldigt, dass ich aufgrund meiner Fehlannahme eure Zeit verschwendet habe 😞

    Haste nicht 😉


Anmelden zum Antworten