- Bridge provides a C++11 subset playground even if no C++11 is present.
- Bridge provides a few macro utils, aimed to cross-development.
- Bridge pollutes macros on purpose. Sorry but I think this is convenient.
- Bridge is cross-platform.
- Bridge is header-only.
- Bridge is zlib/libpng licensed.
- on C++11 platforms, bridge includes a few c++11 headers only.
- on C++03 platforms, bridge fallbacks to a few boost libraries.
- additionally 128-bit headers are included if possible.
- bridge recreates a safe std:: playground that wraps all
std::mutex
variants,std::thread
,std::function
,std::bind
,std::placeholders
andstd::(u)int\*_t
types (for now).
{
std::thread( classA() ).detach();
std::mutex m;
std::scope_lock guard(m);
std::function<int(int,const char**)> fn( main );
using namespace std::placeholders;
return std::bind( fn, _1 );
}
- Bridge macros can contain multiline text and/or code
- These macros can be located inside functions, global namespaces, and #if directives.
$tls(x)
static $tls(bool) acquired = false;
$windows(...)
,$welse(...)
$linux(...)
,$lelse(...)
$apple(...)
,$aelse(...)
$ios(...)
,$ielse(...)
$osx(...)
,$oelse(...)
$undefined_os(...)
int dir() {
$windows( return system("dir") );
$welse( return system("ls -la") );
return 0;
}
$msvc(...)
,$melse(...)
$gnuc(...)
,$gelse(...)
$clang(...)
,$celse(...)
$undefined_compiler(...)
int main() {
$msvc( __asm int 3 );
}
$throw(...)
,$telse(...)
int main() {
$throw(
try {
setup();
game();
} catch(...) {
/*...*/
}
);
$telse(
setup();
game();
);
}
$debug(...)
,$release(...)
int main() {
// disable logging
$release({
fclose(stderr);
fclose(stdout)
});
}
$warning(...)
$todo(...)
$warning("line printed in compile time");
$todo("cook food");
int main()
{}
$on(...)
$is(...)
$has(...)
#if $on($windows))
# include <windows.h>
#else
# include <unistd.h>
#endif
int main()
if( $on($linux) && $on($release) ) {
print("linux-release");
}
}
$quote(...)
std::string text = $quote(
this is a multine
string
);
$comment(...)
,$uncomment(...)
int main() {
$comment(
print("this code...");
print("...is never compiled");
);
}
$cpp03(...)
$cpp11(...)
$cpp11(std::unique_ptr) $cpp03(std::auto_ptr) <std::string> str( new std::string("hi") );
$bits32(...)
$bits64(...)
$likely(expr)
$unlikely(expr)
- v1.0.0 (2016/04/11): Initial semantic versioning adherence; add $osx and $ios