Skip to content

Instantly share code, notes, and snippets.

@niklasfi
Created May 14, 2011 21:03
Show Gist options
  • Save niklasfi/972631 to your computer and use it in GitHub Desktop.
Save niklasfi/972631 to your computer and use it in GitHub Desktop.
g++ --std=c++0x -c ui2.cpp
g++ --std=c++0x test.cpp ui2.o
/tmp/cc4DASkN.o: In function `main':
test.cpp:(.text+0x20): undefined reference to `std::function<bool (int const&)> ui2::check_true<int>()'
collect2: ld gab 1 als Ende-Status zurüc
#include "ui2.h"
int main(){
std::cout << ui2::quert(4) << "\n" //works
<< ui2::check_true<int>()(4) << "\n"; //does not link!
}
#include "ui2.h"
int ui2::quert(int bar){return bar;};
template <class T> std::function<bool(const T&)> ui2::check_true(){
return [](const T& m) { return true; };
}
#pragma once
#include <functional>
namespace ui2{
int quert(int bar);
template <class T> std::function<bool(const T&)> check_true();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment