以下代码适用于gcc-4.8.2
#include <iostream>
using namespace std;
template<typename... Args>
void func(Args... args, int optional = 0)
{
cout << optional << endl;
}
int main()
{
func(1);
func(2.1f); // converts 2.1 to int as 'optional' parameter
func<float>(3.3f); // Fine, prints '0'
func(); // gcc OK, fails to compile with clang-3.5
}
Run Code Online (Sandbox Code Playgroud)
它输出:
$ ./a.out
1
2
0
0
Run Code Online (Sandbox Code Playgroud)
但是如果用clang-3.5编译失败,
test_variadic.cpp:15:2: error: no matching function for call to 'func'
func();
^~~~
test_variadic.cpp:5:6: note: candidate function template not viable: requires at least argument …Run Code Online (Sandbox Code Playgroud) 正如这个问题所指出的,boost :: asio现在可以使用C++ 11 chrono对象(如果可用).但是,以下代码与clang 3.6.0-svn223366-1~exp1编译但不编译
#include <iostream>
#include <boost/chrono.hpp>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/asio/steady_timer.hpp>
#include <chrono>
#include <thread>
#include <functional>
boost::asio::io_service ioservice;
boost::asio::steady_timer timer(ioservice);
void function()
{
std::cout << "Success" << std::endl;
}
int main()
{
std::thread t([&]{ ioservice.run(); });
t.detach();
timer.expires_from_now(std::chrono::milliseconds(10));
timer.async_wait(boost::bind(&function));
std::this_thread::sleep_for(std::chrono::seconds(1));
}
Run Code Online (Sandbox Code Playgroud)
GCC:
~/scratch$ g++ -std=c++11 test_asio_chrono_broken.cpp -lpthread -lboost_system -lboost_chrono
~/scratch$ ./a.out
Success
Run Code Online (Sandbox Code Playgroud)
gcc和boost很高兴使用std :: chrono
然而,铿锵:
~/scratch$ clang++-3.6 -std=c++11 test_asio_chrono_broken.cpp -lpthread -lboost_system -lboost_chrono
test_asio_chrono_broken.cpp:23:8: error: no matching member function for call to …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Admob向我的Android应用添加广告,但已经碰到了一堵墙.Admob表示需要以下内容logcat
E/Ads (26043): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
E/Ads (26043): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
E/Ads (26043): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
Run Code Online (Sandbox Code Playgroud)
但是,Ubuntu上的Eclipse中的Android SDK无法解析以下内容,
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Run Code Online (Sandbox Code Playgroud)
当我转到活动并在清单中选择属性时,最后三个项目显示"无法识别的标志".
我想在Android 1.6(API级别4)上添加广告,但这些属性在青少年的API级别之前不存在.我如何调和这个?