As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [inline-variable]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
1 answer
83 views

Initialization order of inline variables

Assume I have the following three files. header.h: int SomeFunction(); inline int a = SomeFunction(); file1.cpp: #include "header.h" int b = a + 5; file2.cpp #include "header.h" ...
dgnuff's user avatar
  • 3,155
9 votes
1 answer
336 views

Static initialization order of inline variables in single TU

I'm aware this question has been asked many times, but this seems to be a slightly different variation which I can't figure out. Consider the following code: #include <cstdio> struct TestValue; ...
tchatow's user avatar
  • 738
0 votes
1 answer
927 views

inline static constexpr vs global inline constexpr

Suppose that I have a few inline constexpr variables (named as default_y and default_x) in a header file and I decided to move them to a class that they are completely related to and mark them static (...
digito_evo's user avatar
  • 3,154
2 votes
0 answers
18 views

Python: Multiline strings with inline variables [duplicate]

I'm trying to use inline variables in the multiline string to form a GraphQL query. query = '''query { gapc { search_gapc_parts(part_number: "xxx", query: "XXX" limit: 1) { ...
Ali Guliyev's user avatar
1 vote
1 answer
269 views

Inline declarations: var vs const

When I use inline declarations, should I prefer const over var? In all online examples, and even in Delphi's own documentation, I see that var is being used. However, I think that const often better ...
Wouter van Nifterick's user avatar
0 votes
0 answers
326 views

Inline variables in loops

What happens if inline variables are used inside a loop: for i := 1 to N do begin for var j := 1 to M do begin { Do something with i and j } end; end; The scope of the variable j ...
Matej's user avatar
  • 442
1 vote
1 answer
184 views

How to inline static array variables in Rio

I am failing to inline constructs such as var FileName: array[0..2047] of Char; This works: procedure TForm1.AcceptFiles(var Msg: TWMDropFiles); var FileName: array[0..2047] of Char; begin ...
Gad D Lord's user avatar
  • 6,558
6 votes
1 answer
346 views

Why isn't inv_sqrt2 defined in the C++ standard library?

C++20 introduces standard library header, <numbers>, with definitions in namespace std::numbers for math constants such as sqrt2 and sqrt3. It provide inverse values like inv_sqrt3, but not ...
John McFarlane's user avatar
1 vote
1 answer
197 views

Initialization of inline static data

I am wondering how and when static inline data is initialized in C++ (for example in gcc or clang). I know it is a question specific to some architecture and it is not related to the C++ standard. I ...
roy cabouly's user avatar
0 votes
1 answer
52 views

In total.js is it possible to assign value to variables or save/use the index of a @{foreach...} inside a nested @{foreach...} inline in the HTML?

for example is it possible to define/use an "item_index" in a similar example to this: <div> @{foreach item in list} <p>@{item.title}:<p> @{foreach content in item.contents} ...
Garen's user avatar
  • 30
4 votes
1 answer
169 views

Multiple destruction of an inline variable [duplicate]

Here is a header file containing an inline variable: // inline.hpp #pragma once #include <iostream> struct Test { ~Test() { std::cout << "deleted" << std::endl; } }; inline ...
slyx's user avatar
  • 2,053
6 votes
1 answer
480 views

When are inline variables in static storage initialized?

C++ standards (earlier than C++17, at least) have said this about initialization order. Objects with static storage duration defined in namespace scope in the same translation unit and dynamically ...
Drew Dormann's user avatar
  • 59.2k
4 votes
2 answers
1k views

Inline std::mutex in header file

I am using a global std::mutex in different cpp files. Is it okay to declare it in a header file as inline? inline std::mutex mtx; Is mtx constructed this way? Should it be initialized ...
Loreto's user avatar
  • 674
1 vote
1 answer
271 views

postgres - inline variable assignment from select

In SQL Server it's possible to do inline variable assignment. For example, table dbo.tblSynonym: +--+-------+-----------+ |id|keyword|replacement| +--+-------+-----------+ |1 |aaa |bbb ...
NirKa's user avatar
  • 677
24 votes
3 answers
2k views

Are inline variables unique across boundaries?

This is a follow up of this question. As mentioned in the comments to the answer: An inline variable has the property that - It has the same address in every translation unit. [...] Usually you ...
skypjack's user avatar
  • 49k
3 votes
1 answer
132 views

Any potential pitfall of using inline static data member?

C++17 introduced inline variable, and an inline static data member can be defined in the class definition with an initializer. It does not need an out-of-class definition. For example, struct X { ...
Lingxi's user avatar
  • 14.6k
12 votes
1 answer
5k views

Are all constexpr variable implicitly inline?

I was playing around with auto template parameters and I was surprised that this code didn't compiled: constexpr auto bar = 2; template<auto& T> struct Foo { auto operator()() const { ...
Guillaume Racicot's user avatar
0 votes
0 answers
50 views

Any specific reason for variable templates in the standard library be inline? [duplicate]

C++17 introduced various helper variable templates, e.g., template< class T, class U > inline constexpr bool is_same_v = is_same<T, U>::value; template< class T > inline constexpr ...
Lingxi's user avatar
  • 14.6k
1 vote
2 answers
792 views

Defining global constexpr variables in anonymous namespace the same as making them inline?

Following up on Why does cppreference define type_traits xxx_v shortcuts as inline constexpr and not just constexpr?, if I make my own type trait and want to avoid ODR violations and want it to be ...
Danra's user avatar
  • 9,466
22 votes
2 answers
1k views

Why does cppreference define type_traits xxx_v shortcuts as inline constexpr and not just constexpr?

Why does cppreference define type_traits xxx_v shortcuts as inline constexpr and not just constexpr? For example, see is_integral_v: template< class T > inline constexpr bool is_integral_v = ...
Danra's user avatar
  • 9,466
5 votes
1 answer
370 views

Initializer "sizeof(T)" of inline static auto... Does it need instantiation?

What should happen if an expression's type is not dependent, but we use it to initialize a static auto variable? GCC and Clang differ in their behavior template<typename T> struct A { ...
Johannes Schaub - litb's user avatar