boostorg / boostorg/histogram

Introducing `variable_t` and similar types for convenience

Ouverte
#378 9 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C++
Étoiles
334
Forks
76
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

@HDembinski Here are some examples why using `variable_t` can bring convenience.

```C++
std::is_same_v<
boost::histogram::axis::variable,
boost::histogram::axis::variable
>
```
is `false`,
```C++
std::is_same_v<
boost::histogram::axis::variable_t,
boost::histogram::axis::variable_t
>
```
is `true`;

---

This causes a compile error:
```C++
boost::histogram::axis::variable a;
boost::histogram::axis::variable b;
a = b;
```
This does not cause a compile error:
```C++
boost::histogram::axis::variable_t a;
boost::histogram::axis::variable_t b;
a = b;
```

---

In templates, you can get the meta type, options type, allocator type conveniently if template users write `variable_t`, not if template users write `variable`:
```
template
void f(boost::histogram::axis::variable)
{
std::cout << typeid(V).name() << '\n';
std::cout << typeid(M).name() << '\n';
std::cout << typeid(O).name() << '\n';
std::cout << typeid(A).name() << '\n';
}

int main(int argc, char *argv[])
{
f(boost::histogram::axis::variable<>());
//double
//struct boost::use_default
//struct boost::use_default
//class std::allocator

f(boost::histogram::axis::variable_t<>());
//double
//class std::basic_string,class std::allocator >
//struct boost::histogram::axis::option::bitset<3>
//class std::allocator
}
```

---

In debugger, you can not see what options `a` has but can see what options `b` has:
![image](https://user-images.githubusercontent.com/5171262/209428440-790b9979-b09b-475a-b231-45c61ae69506.png)
```C++
boost::histogram::axis::variable<> a;
boost::histogram::axis::variable_t<> b;
```

_Originally posted by @jhcarl0814 in https://github.com/boostorg/histogram/issues/372#issuecomment-1364494250_

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.