小编Rob*_*juk的帖子

将本机包sha-1用于未计算的文件(无法从资产中加载脚本index.android.bundle)

我使用的反应原生入门教程创建新RN app.after安装时,我尝试运行我刚刚创建的应用程序,我得到这个错误:

无法从资产index.android.bundle加载脚本

经过很多关于这方面的研究导致我做捆绑,但是当我捆绑这个命令时

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

文件c:\ Users\mehrdad\Desktop\WorkSpace\ReactNative\awesomeproject\index.js的SHA-1未计算

我的问题仍然存在

"react": "16.4.1",

"react-native": "0.56.0",

"windows 8.1"
Run Code Online (Sandbox Code Playgroud)

react-native

8
推荐指数
6
解决办法
3712
查看次数

字符转换函数 std::isupper() & std::islower() C++17

我创建了一个简单的程序来检查用户输入的字母是大写还是小写,然后使用std::isupper()andstd::islower()函数将小写转换为大写,将大写转换为小写。在运行代码时,我得到了数字形式的字符转换,而不是预期的大写/小写等价物。这是为什么?

#include <iostream>

int main()
{
    char letter {};

    std::cout << "Enter a letter:";

    std::cin >> letter;

    if (std::isupper(letter))
    {
        std::cout << "You entered an uppercase letter"
                     "\n"
                     "the lowercase equivalent is:"
                  << std::tolower(letter);
    }

    if (std::islower(letter))    
    {
        std::cout << "You entered a lowercase letter"
                     "\n"
                     "the uppercase equivalent is:"
                  << std::toupper(letter);
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

下面是一个输出示例:

Enter a letter:F
You entered an uppercase letter.
The lowercase equivalent is:102

Enter a letter:f
You entered a lowercase …
Run Code Online (Sandbox Code Playgroud)

c++ c++17

6
推荐指数
2
解决办法
189
查看次数

Is there any way to swap nodes in std::list?

I'm implementing LRUCache, where in unordered_map I store an iterator to list. When I move the most "fresh" element to the head, I need to iterator not changed.

I need to swap exactly nodes, not values in nodes. I'm finding the way to do it.

I tried to do it with std::iter_swap, but it's just implemented as std::swap(*it_first, *it_second)

std::list<std::string> list;
list.emplace_back("first");
list.emplace_back("second");

auto it_first = list.begin();
auto it_second = ++list.begin();

std::iter_swap(it_first, it_second);

assert(list.begin() == it_second); 
Run Code Online (Sandbox Code Playgroud)

I need to swap …

c++

5
推荐指数
1
解决办法
107
查看次数

传递 const 变量时编译器返回错误:模板参数不是常量表达式

所以我写了这段代码->

#include <iostream>
#include <bitset>

int main(){

    int num, temp, digits = 0;
    std::cin >> num;
    temp = num;

    while(temp){
        temp /= 10;
        ++digits;
    }

    const int size = digits;

    std::bitset<size> a(num);
    std::cout << a << std::endl;

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

位集容器不接受 const 整数大小作为参数并抛出错误 - Non-type template argument is not a constant expression。我想知道为什么会发生这种情况,因为大小已被声明为常量,并且它的值在程序运行时不会改变?

c++ constants bitset std-bitset

3
推荐指数
1
解决办法
867
查看次数

在派生函数中指定 void* 参数

我想做一些在 Cpp 中可能无法实现的事情,但我找不到专门针对此的帖子。

我想让派生类指定虚函数上的 void* 参数的类型。

我有一个名为 interface 的基类,带有一个发送函数。

// pure virtual
class Interface{
    virtual bool Send(const void*)=0;

};

struct Packet{
    DataType data;
};

class SpecificInterface{
     bool Send(const DataType*);
}
Run Code Online (Sandbox Code Playgroud)

有没有办法让这样的工作?意图是SpecificInterface::Send 实现Interface::Send。允许特定接口不是纯虚拟的,同时将 void* 限制为特定的数据包类型。

否则我知道我可以使用 void* 参数并将其 static_cast 转换为 Packet* 类型;但是,我不希望其他人发送无法转换为 Packet* 的指针类型。

如果这不清楚,请告诉我

c++ inheritance void-pointers

2
推荐指数
1
解决办法
83
查看次数

for循环的两个代码有什么区别?

#include <vector>
#include <iostream>
using namespace std;

int main(void)
{
    vector<int> a = {1, 2, 3, 4, 5};
    for (auto &x : a)
        cout << x << endl;
}
Run Code Online (Sandbox Code Playgroud)
#include <vector>
#include <iostream>
using namespace std;

int main(void)
{
    vector<int> a = {1, 2, 3, 4, 5};
    for (auto x : a)
        cout << x << endl;
}
Run Code Online (Sandbox Code Playgroud)

上面的两个代码打印相同的值(1、2、3、4、5)。但是初始化 &x 和 x 之间有什么不同吗?谢谢阅读!

c++ reference auto range-based-loop

2
推荐指数
1
解决办法
67
查看次数

“&amp;”、0x000000FF、&gt;&gt; 8 有什么用?

下面的方法中&0x000000FF>> 8有什么用 ?谁能解释一下吗?

\n\n

提前致谢

\n\n
(UIColor *)UIColorFromIntegerCode:(int)integerCode\xc2\xa0 {    \n    CGFloat r = (integerCode & 0x000000FF) / 255.0f;\n\xc2\xa0 \xc2\xa0 CGFloat g = ((integerCode & 0x0000FF00) >> 8) / 255.0f;\n\xc2\xa0 \xc2\xa0 CGFloat b = ((integerCode & 0x00FF0000) >> 16) / 255.0f;\n\n\xc2\xa0 \xc2\xa0 return [UIColor colorWithRed:r green:g blue:b alpha:1.0f];\n}\n
Run Code Online (Sandbox Code Playgroud)\n

hex objective-c uicolor ios

-2
推荐指数
1
解决办法
7719
查看次数