别想她

文章 评论 浏览 27

别想她 2025-02-16 23:09:04

我放置Jlborges的出色 wornge ,因为这是我阅读的有关该主题的最简洁的解释。

在我们编写的模板中,有两种可以使用的名称 - 相关名称和非依赖性名称。依赖名称是取决于模板参数的名称;非依赖性名称具有相同的含义,无论模板参数是什么。

例如:

 模板< T> typename void foo(t& x,std :: string str,int count)
{
    //这些名称在第二阶段查找
    //当实例化FOO并已知T型时
    X.Size(); //依赖名称(非类型)
    t :: instance_count; //依赖名称(非类型)
    typename t :: iterator i; //依赖名称(类型)
      
    //在第一阶段, 
    // t :: instance_count被视为非类型(这是默认值)
    // TypEname关键字指定t :: iterator被视为一种类型。

    //这些名称在第一阶段查找
    std :: string :: size_type s; //非依赖性名称(类型)
    std :: string :: npos; //非依赖性名称(非类型)
    str.empty(); //非依赖性名称(非类型)
    数数 ; //非依赖性名称(非类型)
}
 

对于模板的每个不同实例化而言,依赖名称所指的内容可能是不同的。结果,C ++模板受“两相名称查找”的约束。当最初解析模板(在发生任何实例化之前)时,编译器查找非依赖性名称。当发生模板的特定实例化时,模板参数会在当时知道,并且编译器查找相关名称。

在第一阶段,解析器需要知道因名称是类型的名称还是非类型的名称。默认情况下,假定依赖的名称为非类型的名称。依赖名称之前的打字名称关键字指定它是类型的名称。


摘要

仅在模板声明和定义中使用关键字TypeName,前提是您具有指称类型的合格名称,并取决于模板参数。

I am placing JLBorges's excellent response to a similar question verbatim from cplusplus.com, as it is the most succinct explanation I've read on the subject.

In a template that we write, there are two kinds of names that could be used - dependant names and non- dependant names. A dependant name is a name that depends on a template parameter; a non-dependant name has the same meaning irrespective of what the template parameters are.

For example:

template< typename T > void foo( T& x, std::string str, int count )
{
    // these names are looked up during the second phase
    // when foo is instantiated and the type T is known
    x.size(); // dependant name (non-type)
    T::instance_count ; // dependant name (non-type)
    typename T::iterator i ; // dependant name (type)
      
    // during the first phase, 
    // T::instance_count is treated as a non-type (this is the default)
    // the typename keyword specifies that T::iterator is to be treated as a type.

    // these names are looked up during the first phase
    std::string::size_type s ; // non-dependant name (type)
    std::string::npos ; // non-dependant name (non-type)
    str.empty() ; // non-dependant name (non-type)
    count ; // non-dependant name (non-type)
}

What a dependant name refers to could be something different for each different instantiation of the template. As a consequence, C++ templates are subject to "two-phase name lookup". When a template is initially parsed (before any instantiation takes place) the compiler looks up the non-dependent names. When a particular instantiation of the template takes place, the template parameters are known by then, and the compiler looks up dependent names.

During the first phase, the parser needs to know if a dependant name is the name of a type or the name of a non-type. By default, a dependant name is assumed to be the name of a non-type. The typename keyword before a dependant name specifies that it is the name of a type.


Summary

Use the keyword typename only in template declarations and definitions provided you have a qualified name that refers to a type and depends on a template parameter.

我必须在何处以及为什么要放置“模板”。和“ typename”关键字?

别想她 2025-02-16 16:31:21

您可以采用几种方法。

  1. 后滤器您的数组

    [5,value] .filter((v)=&gt; v)

  2. 使用everper opperator

    [5,... value? [value]:[]]

  3. 有条件添加

    const example = [5];价值&amp;&amp; example.push(value);

You can have several approaches.

  1. Post-filter your array

    [5, value].filter((v) => v)

  2. Use spread opperator

    [5, ...value ? [value] : []]

  3. Add conditionally

    const example = [5]; value && example.push(value);

删除在JavaScript中falsy中的数据中删除数据

别想她 2025-02-16 01:20:32

您已经朝着正确的方向思考,但仍然缺少将代码和许多其他细节放在哪里。

有关最新更新的游戏的整个工作代码,请查看我对您的最初问题的答案(当前三个)的答案(首先是三个),请 https ://stackoverflow.com/a/72694075/7711283

在那里,您可以看到在哪里放置用于收集坐标的代码以及如何评估它们。

You are thinking already in the right direction, but still missing the point where to put the code and many other details.

For the entire working code of the game with newest updates check out my answer to your initial question (first in a series of currently three) at https://stackoverflow.com/a/72694075/7711283 .

There you can see where to put the code for collecting the coordinates and how to evaluate them.

Tron与Turtle图形中生成的线相撞

别想她 2025-02-15 16:58:48

根据,要从嵌入式资源加载图像

Image embeddedImage = new Image
{
    Source = ImageSource.FromResource("WorkingWithImages.beach.jpg", typeof(MyClass).GetTypeInfo().Assembly)
};

,其中 myClass 是与图像同一组件中的类的名称

according to the docs, to load an image from an embedded resource

Image embeddedImage = new Image
{
    Source = ImageSource.FromResource("WorkingWithImages.beach.jpg", typeof(MyClass).GetTypeInfo().Assembly)
};

where MyClass is the name of a class that is located in the same assembly as the images

Xamarin加载图片带有C#用于创建列表

别想她 2025-02-15 08:52:59

当您进行 FindbyId 时,我相信您想使用 ObjectID 而不是字符串值搜索。我会更新您的 insertuser 函数

override suspend fun insertUser(user: User): ObjectId? {
    return users.insertOne(user).insertedId.asObjectId().value
}

,然后 getuser 像这样的

override suspend fun getUser(userId: ObjectId): User? {
    return users.findOneById(userId)
}

希望这会有所帮助!

When you do your findById, I believe you want to search using an ObjectId instead of the string value. I would update your insertUser function as so

override suspend fun insertUser(user: User): ObjectId? {
    return users.insertOne(user).insertedId.asObjectId().value
}

and getUser like this

override suspend fun getUser(userId: ObjectId): User? {
    return users.findOneById(userId)
}

Hope this helps!

插入后,如何从MongoDB文档中返回插入性。尝试了插入式,但它返回了null

别想她 2025-02-14 14:22:35

我认为您可以简单地传递列表:

new_df1 = df1[~df1.ID.isin(filtration_1)]
new_df2 = df2[~df2.ID.isin(filtration_2)]
new_df3 = df3[~df3.ID.isin(filtration_3)]

frames = [new_df1, new_df2, new_df3]
df = pd.concat(frames)

解决方案不起作用的原因是 lines1,lines2,lines 3 不是预期-Lists filtration_1,filtration_1,filtration_2,filtration_3

I think you can simply pass lists:

new_df1 = df1[~df1.ID.isin(filtration_1)]
new_df2 = df2[~df2.ID.isin(filtration_2)]
new_df3 = df3[~df3.ID.isin(filtration_3)]

frames = [new_df1, new_df2, new_df3]
df = pd.concat(frames)

Reason why solution not working is in lines1, lines2, lines3 is not what expected - lists filtration_1,filtration_2, filtration_3.

数据框在不同的过滤列表中看起来相同

别想她 2025-02-14 07:58:06
main_list = ['', 'Apple', 'Apple', 'Apple', 'Apple', 'bat', 'bat', 
            'bat1', 'bat', 'cat', 'cat', 'cat', 'cat1', 'cat', 'cat']
append_list = []

for prev_item, item in zip(main_list, main_list[1:]):
    if prev_item != item:
        append_list.append(item)
    print(prev_item, item)
    print(append_list)
main_list = ['', 'Apple', 'Apple', 'Apple', 'Apple', 'bat', 'bat', 
            'bat1', 'bat', 'cat', 'cat', 'cat', 'cat1', 'cat', 'cat']
append_list = []

for prev_item, item in zip(main_list, main_list[1:]):
    if prev_item != item:
        append_list.append(item)
    print(prev_item, item)
    print(append_list)

将循环的先前值存储在Python中

别想她 2025-02-13 15:03:29

comparator.compare(t o1,t o2) javadoc state (添加了强调):

返回:A 整数,正面整数
因为第一个论点小于,等于或大于
第二。

因此,在最小上,您的测试需要涵盖上述三个条件:

class SortByEmployeeIdByDescTest {

    @Test
    void compareEmployees() {
        final List<Employee> employees = Stream.of("2", "1", "3", "2")
                .map(id -> Employee.builder().empId(id).build())
                .collect(Collectors.toList());

        Collections.sort(employees, new SortByEmployeeIdByDesc());

        assertThat(employees).extracting(Employee::getEmpId)
                .containsExactly("3", "2", "2", "1");
    }
}

我正在使用 assertj 在此示例中,强烈建议您在项目中使用它。

此外,您的员工ID是字符串。因此,您需要进行测试,以便它是 null 。然后,您将获得所需的覆盖范围。

The Comparator.compare(T o1, T o2) javadoc states (emphasis added):

Returns: a negative integer, zero, or a positive integer
as the first argument is less than, equal to, or greater than the
second.

Therefore, at the minimum your test needs to cover the above three conditions:

class SortByEmployeeIdByDescTest {

    @Test
    void compareEmployees() {
        final List<Employee> employees = Stream.of("2", "1", "3", "2")
                .map(id -> Employee.builder().empId(id).build())
                .collect(Collectors.toList());

        Collections.sort(employees, new SortByEmployeeIdByDesc());

        assertThat(employees).extracting(Employee::getEmpId)
                .containsExactly("3", "2", "2", "1");
    }
}

I'm using AssertJ in this example and highly recommend using it in your projects.

In addition, your employee id is a String. So you need a test for when it's null. Then you will have the desired coverage.

如何编写JUNIT测试案例以进行比较代码覆盖

别想她 2025-02-13 07:51:41

我想出的一个解决方法只是使用 os.getPid(),这在每个工人中都是唯一的。虽然这可以完成工作,并允许我创建唯一的登录名称,但我仍然想知道是否有更好的方法。

One workaround that I came up with is simply using os.getpid(), which will be unique in each worker. While this does the job and allows me to create unique names for logging, I'm still wondering if there is a better way.

从枪支中的多名工人登记

别想她 2025-02-12 11:57:43

这是 tidyverse 解决方案

library(tidyverse)

df <- dplyr::tribble(
  ~id, ~Country, ~City, ~Accrued_Jan, ~Accrued_Feb, ~Accrued_Mar, ~Paid_Jan, ~Paid_Feb, ~Paid_Mar,
  1, "USA", "NY", 100, 110, 130, 100, 100, 110,
  2, "Italy", "Rome", 80, 90, 100, 70, 70, 90,
  3, "France", "Paris", 70, 80, 90, 70, 70, 90) %>% 
  tidyr::pivot_longer(
    cols = -c(id, Country, City),
    names_to = c("name", "month"),
    names_sep = "_",
    values_to = "value") %>% 
  tidyr::pivot_wider(names_from = name, values_from = value)

Here is a tidyverse solution

library(tidyverse)

df <- dplyr::tribble(
  ~id, ~Country, ~City, ~Accrued_Jan, ~Accrued_Feb, ~Accrued_Mar, ~Paid_Jan, ~Paid_Feb, ~Paid_Mar,
  1, "USA", "NY", 100, 110, 130, 100, 100, 110,
  2, "Italy", "Rome", 80, 90, 100, 70, 70, 90,
  3, "France", "Paris", 70, 80, 90, 70, 70, 90) %>% 
  tidyr::pivot_longer(
    cols = -c(id, Country, City),
    names_to = c("name", "month"),
    names_sep = "_",
    values_to = "value") %>% 
  tidyr::pivot_wider(names_from = name, values_from = value)

我如何修改数据集(我有几个列,相同的变量按月分开(宽格式),我想长时间构建它)

别想她 2025-02-12 11:28:14

您需要用后斜切逃脱字符串的某些部分:

'C: \Users\AZERTY\Desktop\\1.1 pandas.zip\\2021\\'

假设您获得了 string字面的字体是不确定的错误

为什么“ \ 1”在三重引用的字符串中评估到Unicode 0x1代码点

You need to escape some parts of your string with a backslash:

'C: \Users\AZERTY\Desktop\\1.1 pandas.zip\\2021\\'

Assuming you are getting a string literal is undetermined error

Why does "\1" inside a triple-quoted string evaluate to a unicode 0x1 code point

通过文件夹中的文件循环,读取和分组文件

别想她 2025-02-12 05:20:22

您可以使用XTS函数,提取索引,然后将其转换为日期格式:

library(xts)
as.Date(index(as.xts(Seatbelts)), format = "%M %Y")

输出:

  [1] "1969-01-01" "1969-02-01" "1969-03-01" "1969-04-01" "1969-05-01" "1969-06-01" "1969-07-01" "1969-08-01"
  [9] "1969-09-01" "1969-10-01" "1969-11-01" "1969-12-01" "1970-01-01" "1970-02-01" "1970-03-01" "1970-04-01"
 [17] "1970-05-01" "1970-06-01" "1970-07-01" "1970-08-01" "1970-09-01" "1970-10-01" "1970-11-01" "1970-12-01"
 [25] "1971-01-01" "1971-02-01" "1971-03-01" "1971-04-01" "1971-05-01" "1971-06-01" "1971-07-01" "1971-08-01"
 [33] "1971-09-01" "1971-10-01" "1971-11-01" "1971-12-01" "1972-01-01" "1972-02-01" "1972-03-01" "1972-04-01"
 [41] "1972-05-01" "1972-06-01" "1972-07-01" "1972-08-01" "1972-09-01" "1972-10-01" "1972-11-01" "1972-12-01"
 [49] "1973-01-01" "1973-02-01" "1973-03-01" "1973-04-01" "1973-05-01" "1973-06-01" "1973-07-01" "1973-08-01"
 [57] "1973-09-01" "1973-10-01" "1973-11-01" "1973-12-01" "1974-01-01" "1974-02-01" "1974-03-01" "1974-04-01"
 [65] "1974-05-01" "1974-06-01" "1974-07-01" "1974-08-01" "1974-09-01" "1974-10-01" "1974-11-01" "1974-12-01"
 [73] "1975-01-01" "1975-02-01" "1975-03-01" "1975-04-01" "1975-05-01" "1975-06-01" "1975-07-01" "1975-08-01"
 [81] "1975-09-01" "1975-10-01" "1975-11-01" "1975-12-01" "1976-01-01" "1976-02-01" "1976-03-01" "1976-04-01"
 [89] "1976-05-01" "1976-06-01" "1976-07-01" "1976-08-01" "1976-09-01" "1976-10-01" "1976-11-01" "1976-12-01"
 [97] "1977-01-01" "1977-02-01" "1977-03-01" "1977-04-01" "1977-05-01" "1977-06-01" "1977-07-01" "1977-08-01"
[105] "1977-09-01" "1977-10-01" "1977-11-01" "1977-12-01" "1978-01-01" "1978-02-01" "1978-03-01" "1978-04-01"
[113] "1978-05-01" "1978-06-01" "1978-07-01" "1978-08-01" "1978-09-01" "1978-10-01" "1978-11-01" "1978-12-01"
[121] "1979-01-01" "1979-02-01" "1979-03-01" "1979-04-01" "1979-05-01" "1979-06-01" "1979-07-01" "1979-08-01"
[129] "1979-09-01" "1979-10-01" "1979-11-01" "1979-12-01" "1980-01-01" "1980-02-01" "1980-03-01" "1980-04-01"
[137] "1980-05-01" "1980-06-01" "1980-07-01" "1980-08-01" "1980-09-01" "1980-10-01" "1980-11-01" "1980-12-01"
[145] "1981-01-01" "1981-02-01" "1981-03-01" "1981-04-01" "1981-05-01" "1981-06-01" "1981-07-01" "1981-08-01"
[153] "1981-09-01" "1981-10-01" "1981-11-01" "1981-12-01" "1982-01-01" "1982-02-01" "1982-03-01" "1982-04-01"
[161] "1982-05-01" "1982-06-01" "1982-07-01" "1982-08-01" "1982-09-01" "1982-10-01" "1982-11-01" "1982-12-01"
[169] "1983-01-01" "1983-02-01" "1983-03-01" "1983-04-01" "1983-05-01" "1983-06-01" "1983-07-01" "1983-08-01"
[177] "1983-09-01" "1983-10-01" "1983-11-01" "1983-12-01" "1984-01-01" "1984-02-01" "1984-03-01" "1984-04-01"
[185] "1984-05-01" "1984-06-01" "1984-07-01" "1984-08-01" "1984-09-01" "1984-10-01" "1984-11-01" "1984-12-01"

You can use the xts function, extract the index and then convert it into a date format:

library(xts)
as.Date(index(as.xts(Seatbelts)), format = "%M %Y")

Output:

  [1] "1969-01-01" "1969-02-01" "1969-03-01" "1969-04-01" "1969-05-01" "1969-06-01" "1969-07-01" "1969-08-01"
  [9] "1969-09-01" "1969-10-01" "1969-11-01" "1969-12-01" "1970-01-01" "1970-02-01" "1970-03-01" "1970-04-01"
 [17] "1970-05-01" "1970-06-01" "1970-07-01" "1970-08-01" "1970-09-01" "1970-10-01" "1970-11-01" "1970-12-01"
 [25] "1971-01-01" "1971-02-01" "1971-03-01" "1971-04-01" "1971-05-01" "1971-06-01" "1971-07-01" "1971-08-01"
 [33] "1971-09-01" "1971-10-01" "1971-11-01" "1971-12-01" "1972-01-01" "1972-02-01" "1972-03-01" "1972-04-01"
 [41] "1972-05-01" "1972-06-01" "1972-07-01" "1972-08-01" "1972-09-01" "1972-10-01" "1972-11-01" "1972-12-01"
 [49] "1973-01-01" "1973-02-01" "1973-03-01" "1973-04-01" "1973-05-01" "1973-06-01" "1973-07-01" "1973-08-01"
 [57] "1973-09-01" "1973-10-01" "1973-11-01" "1973-12-01" "1974-01-01" "1974-02-01" "1974-03-01" "1974-04-01"
 [65] "1974-05-01" "1974-06-01" "1974-07-01" "1974-08-01" "1974-09-01" "1974-10-01" "1974-11-01" "1974-12-01"
 [73] "1975-01-01" "1975-02-01" "1975-03-01" "1975-04-01" "1975-05-01" "1975-06-01" "1975-07-01" "1975-08-01"
 [81] "1975-09-01" "1975-10-01" "1975-11-01" "1975-12-01" "1976-01-01" "1976-02-01" "1976-03-01" "1976-04-01"
 [89] "1976-05-01" "1976-06-01" "1976-07-01" "1976-08-01" "1976-09-01" "1976-10-01" "1976-11-01" "1976-12-01"
 [97] "1977-01-01" "1977-02-01" "1977-03-01" "1977-04-01" "1977-05-01" "1977-06-01" "1977-07-01" "1977-08-01"
[105] "1977-09-01" "1977-10-01" "1977-11-01" "1977-12-01" "1978-01-01" "1978-02-01" "1978-03-01" "1978-04-01"
[113] "1978-05-01" "1978-06-01" "1978-07-01" "1978-08-01" "1978-09-01" "1978-10-01" "1978-11-01" "1978-12-01"
[121] "1979-01-01" "1979-02-01" "1979-03-01" "1979-04-01" "1979-05-01" "1979-06-01" "1979-07-01" "1979-08-01"
[129] "1979-09-01" "1979-10-01" "1979-11-01" "1979-12-01" "1980-01-01" "1980-02-01" "1980-03-01" "1980-04-01"
[137] "1980-05-01" "1980-06-01" "1980-07-01" "1980-08-01" "1980-09-01" "1980-10-01" "1980-11-01" "1980-12-01"
[145] "1981-01-01" "1981-02-01" "1981-03-01" "1981-04-01" "1981-05-01" "1981-06-01" "1981-07-01" "1981-08-01"
[153] "1981-09-01" "1981-10-01" "1981-11-01" "1981-12-01" "1982-01-01" "1982-02-01" "1982-03-01" "1982-04-01"
[161] "1982-05-01" "1982-06-01" "1982-07-01" "1982-08-01" "1982-09-01" "1982-10-01" "1982-11-01" "1982-12-01"
[169] "1983-01-01" "1983-02-01" "1983-03-01" "1983-04-01" "1983-05-01" "1983-06-01" "1983-07-01" "1983-08-01"
[177] "1983-09-01" "1983-10-01" "1983-11-01" "1983-12-01" "1984-01-01" "1984-02-01" "1984-03-01" "1984-04-01"
[185] "1984-05-01" "1984-06-01" "1984-07-01" "1984-08-01" "1984-09-01" "1984-10-01" "1984-11-01" "1984-12-01"

从TS / MTS对象中提取Rownames

别想她 2025-02-11 13:09:52

Try downgrading to [email protected]. This may be needed if this issue occurs without ts-node installed.

错误的表达式:非弦乐值传递到typescript中的`ts.resolvetypeRecredectextive'

别想她 2025-02-11 07:52:12

该文档专注于从我的应用程序中使用另一个应用程序“选择”文件,我只希望我的应用与任意应用程序“共享”文件。

您想要此文档而不是。他们的页面标题(驱动导航)留下了很多不足之处。

我缺少什么?

尝试使用 content,不是*/*

The documentation focuses on having another app "pick" a file from my app, where I just want my app to "share" a file with an arbitrary app.

You want this documentation instead. Their page titles (which drive the navigation) leave a lot to be desired.

What am I missing?

Try using the actual MIME type of the content, not */*.

如何让用户与任意应用共享文件?

别想她 2025-02-10 22:11:37

检查完整://developer.mozilla.org/en-us/docs/web/api/htmlimageelement/naturalalwidth“ rel =“ nofollow noreferrer”> naturalwidth> naturalWidth 元素的属性。您可以使用 href =“ https://testcafe.io/documentation/402759/reference/test-api/selector/addcustomdomdomproperties#header” rel =“ nofollow noreferrer”>“ nofollow noreferrer”> selector selector自定义域。例如:

import { Selector } from 'testcafe';

fixture`Check images`
    .page`google.com`;

test('Test', async t => {
    const image = Selector('img[alt=Google]').addCustomDOMProperties({
        complete:     node => node.complete,
        naturalWidth: node => node.naturalWidth
    });

    await t
        .expect(image.complete).ok()
        .expect(image.naturalWidth).eql(272);
});

Check the complete and naturalWidth properties of the element. You can access them with the ClientFunction or Selector custom DOM properties. For example:

import { Selector } from 'testcafe';

fixture`Check images`
    .page`google.com`;

test('Test', async t => {
    const image = Selector('img[alt=Google]').addCustomDOMProperties({
        complete:     node => node.complete,
        naturalWidth: node => node.naturalWidth
    });

    await t
        .expect(image.complete).ok()
        .expect(image.naturalWidth).eql(272);
});

如何测试图像是否已在testcafe中充满负载

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文