variant

Android Studio: No build variant found error

不羁的心 提交于 2021-02-18 20:17:55
问题 i am new to android development, i started developing from scratch on a project i bought online, following the documentation, i encountered a error saying No variants found for 'app'. Check build files to ensure at least one variant exists. Here is the build.gradle code apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.1" defaultConfig { applicationId "com.app-10.app" minSdkVersion 23 targetSdkVersion 29 versionCode 1 versionName "1.0"

Android Studio: No build variant found error

天大地大妈咪最大 提交于 2021-02-18 20:17:14
问题 i am new to android development, i started developing from scratch on a project i bought online, following the documentation, i encountered a error saying No variants found for 'app'. Check build files to ensure at least one variant exists. Here is the build.gradle code apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.1" defaultConfig { applicationId "com.app-10.app" minSdkVersion 23 targetSdkVersion 29 versionCode 1 versionName "1.0"

Android Studio: No build variant found error

99封情书 提交于 2021-02-18 20:16:23
问题 i am new to android development, i started developing from scratch on a project i bought online, following the documentation, i encountered a error saying No variants found for 'app'. Check build files to ensure at least one variant exists. Here is the build.gradle code apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.1" defaultConfig { applicationId "com.app-10.app" minSdkVersion 23 targetSdkVersion 29 versionCode 1 versionName "1.0"

C++ constexpr in place aligned storage construction

为君一笑 提交于 2021-02-08 02:11:34
问题 I'm trying to make an aligned variant type that uses std::aligned_storage to hold the data. Is there a way to construct an object in place in a constexpr way? I read you can't do constexpr placement new. #include <iostream> #include <string> struct foo { foo(std::string a, float b) : bar1(a), bar2(b) {} std::string bar1; float bar2; }; struct aligned_foo { template<typename... Args> aligned_foo(Args&&... args) { //How to constexpr construct foo? data_ptr = ::new((void*)::std::addressof

C++ constexpr in place aligned storage construction

人盡茶涼 提交于 2021-02-08 02:06:18
问题 I'm trying to make an aligned variant type that uses std::aligned_storage to hold the data. Is there a way to construct an object in place in a constexpr way? I read you can't do constexpr placement new. #include <iostream> #include <string> struct foo { foo(std::string a, float b) : bar1(a), bar2(b) {} std::string bar1; float bar2; }; struct aligned_foo { template<typename... Args> aligned_foo(Args&&... args) { //How to constexpr construct foo? data_ptr = ::new((void*)::std::addressof

Cannot initialize std::variant with various lambda expressions

大城市里の小女人 提交于 2021-02-07 11:23:07
问题 I'm playing with std::variant, lambdas and std::future , and got super weird results when I tried to compose them together. Here are examples: using variant_t = std::variant< std::function<std::future<void>(int)>, std::function<void(int)> >; auto f1 = [](int) { return std::async([] { return 1; }); }; auto f2 = [](int) { return std::async([] { }); }; variant_t v1(std::move(f1)); // !!! why DOES this one compile when it SHOULDN'T? auto idx1 = v1.index(); //equals 1. WHY? variant_t v2(std::move

C++: Is it posible to set the type of a void-pointer, variant-object or any-object in execution time?

孤者浪人 提交于 2021-01-28 23:22:14
问题 Void-pointer, variant-objects and any-objects are amazing because they can store many different types in the same variable. But I have a problem with them, I need to specify their type (creating and/or de-referencing them) in the execution time, is it possible? To be more clear, for example, as far I know, to create and de-reference them I have to do this: void* ptr = new int(8); variant<int, float> var = 8; any a = 8; ... cout << *(int*)ptr; cout << get<int>(var); cout << any_cast<int>(a);

Would a template work for std::variant's visit?

和自甴很熟 提交于 2021-01-27 20:06:40
问题 Earlier I asked this question about std::variant . Considering that the types hold by the variant are all printable by std::cout , is there a simple way to implement a visitor? Here for example, all the way down you have several lambdas to cover each type, but all do the same thing (except std::string ): std::cout << arg << ' '; . Is there a way to not repeat my self? std::visit(overloaded { [](int arg) { std::cout << arg; }, [](long arg) { std::cout << arg; }, [](double arg) { std::cout <<

How to parse json file with std::optional< std::variant > type in C++?

五迷三道 提交于 2020-12-30 04:20:53
问题 How can I parse nested json in c++? I am looking for a json parser that is capable of parsing nested json. Especially this field in the example json below: optional<variant<bool, Secondary>> secondary; It is type composition of optional and variant . Though only the full example can surface the problem in a clearer way, a minimal starting point example would be this one: [ {}, { "secondary": false }, { "secondary": { "chance": 10, "boosts": { "spd": -1 } } }, { "secondary": { "chance": 30,

How to parse json file with std::optional< std::variant > type in C++?

只谈情不闲聊 提交于 2020-12-30 04:06:31
问题 How can I parse nested json in c++? I am looking for a json parser that is capable of parsing nested json. Especially this field in the example json below: optional<variant<bool, Secondary>> secondary; It is type composition of optional and variant . Though only the full example can surface the problem in a clearer way, a minimal starting point example would be this one: [ {}, { "secondary": false }, { "secondary": { "chance": 10, "boosts": { "spd": -1 } } }, { "secondary": { "chance": 30,