• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 09:23
CEST 15:23
KST 22:23
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Serral wins HomeStory Cup 2914Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
ZeroSpace Early Access is Now Live!17Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters2Balance hotfix patch 5.0.16b (July 16)84Reynor: GSL Loss Wasn't About Preparation Format16[IPSL] Spring 2026 Grand Finals - This Weekend!18
StarCraft 2
General
August World Ranking Watchlist: Serral back to #1? How would you feel about frequent/monthly balance patches for SC2? Balance hotfix patch 5.0.16b (July 16) Clem: "I don't have that much hope in Blizzard" Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters
Tourneys
RSL Revival: Season 6 - Qualifiers and Main Event Master Swan Open (Global Bronze-Master 2) WardiTV Summer Cup 2026 GSL CK #5 Race War HomeStory Cup 29
Strategy
[G] Having the right mentality to improve
Custom Maps
[M] (2) Industrial Park New Map Maker - Looking for Advice - Love or Hate
External Content
Mutation # 535 Assembly of Vengeance The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together
Brood War
General
Animated Gateway BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion HORROR STARCRAFT MOVIE How Famous was FlaSh before his Debut?
Tourneys
[Megathread] Daily Proleagues [IPSL] Spring 2026 Grand Finals - This Weekend! Escore Tournament - Season 3 Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers PvT advise for noobs Fighting Spirit mining rates Creating a full chart of Zerg builds
Other Games
General Games
Path of Exile ZeroSpace Early Access is Now Live! General RTS Discussion Thread ZeroSpace at Steam NextFest - Last free demo Nintendo Switch Thread
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Artificial Intelligence Thread How to buy a book - shipping from Korea to Europe The Games Industry And ATVI
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Anime Discussion Thread Series you have seen recently... Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion MLB/Baseball 2023 McBoner: A hockey love story
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Simple Questions Simple Answers FPS when play League Of Legend on laptop
TL Community
Northern Ireland Global Starcraft The Automated Ban List
Blogs
Hello guys!
LIN1s
Role of Gaming on Mental Hea…
TrAiDoS
ASL S22 English Commentary…
namkraft
Poker (part 2)
Nebuchad
An Exploration of th…
waywardstrategy
ramps on octagon
StaticNine
Customize Sidebar...

Website Feedback

Closed Threads



Active: 9573 users

The Big Programming Thread - Page 460

Forum Index > General Forum
Post a Reply
Prev 1 458 459 460 461 462 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 29 2014 07:43 GMT
#9181
On March 29 2014 16:31 Blisse wrote:
Ah right I forgot about auto being old since unique succeeded it, but I don't see how that relates to not using C++ exceptions.

Google's explanation seemed to be countered by the fact that you could use smart pointers but Google didn't use them initially so they don't support them when maintaining legacy code. So I still don't see why you shouldn't be using C++ exceptions if you're smart about it.

Well, the SO post says that exceptions are perfectly fine if your C++ code is solid. If you're dealing with bad C++ code, you're kinda screwed. No matter how good your new code is, old code can crash or leak if you hand it an exception.
If you have a good reason to disagree with the above, please tell me. Thank you.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
March 29 2014 07:50 GMT
#9182
ohhh oops I thought you were the one that said don't use C++ exceptions (that was RoyGBiv) :3 my bad, good to know, all that makes sense.

do you guys know what kind of things i can do to get more experience building embedded things? like building a robot and stuff like that. i hear about arduino and raspi, so i think i'll look at that. anything else you guys have tried?
There is no one like you in the universe.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2014-03-30 08:49:38
March 29 2014 15:35 GMT
#9183
type id to integer and back again

a template tale by nunez

the hype:

templates are awesome. templates employ types. templates, types, battlestar galactica.

if we (me-process, you-process) could talk in types we could use static polymorphism to hammer out responses. our kernel don't know shit about our type-vocabulary, so what's the fastest way to talk in types? here's a wild stab in the dark, which is exactly what will happen to you if you point out any flaws in my approach. we asume we talk in types that only carry semantics and no data, and denote a purely semantic type like that an id. it would be eejy peejy to modify this to accept data as well.

the usual suspects:

all of the following reside in the namespace AUX.

a list of types:
template<class... ts>
struct tl{};

alleged shorthand for calling a type metafunction:
template<class u>
using T=typename u::t;

alleged shorthand for calling a value metafunction:
template<class t>
constexpr decltype(t::v)
V(){ return t::v; }

alleged shorthand for getting the length of a list of types (lets assume length does what it's supposed to):
template<class T>
constexpr int
N(){ return V<length<T>>(); }

alleged shorthand for extracting the index of a type in a typelist (lets assume idx_in does what it's supposed to):
template<class t,class T>
constexpr int
I(){ return V<idx_in<t,T>>(); }


the conversation id

in the quest of talking fast in type ids i will establish a quick framework. first and foremost a concept of a conversation will be defined, with a simple id that denotes some conversation. this is only defined in your mind, as this is the topmost layer of abstraction, your entry point.

struct nunez{};


the vocabulary:

to generate the necessary tools we need to know what type ids (or msg ids) are being talked in in this nunez conversation. establish a type-trait in the namespace GUT like so:

template<class convo_id,class=void>
struct vocab{ static_assert(sizeof(convo)==0,"vocab not defined for convo"); };


with a cursory static check, no default behavior makes sense for a conversation! a implicit assumption is that the message ids are unique and provided as a nested typedef'ed type t in a typelist fashion:

typedef tl<msg_id0,msg_id1,...,msg_idn> t;

it would be fairly trivial to make it explicit by making sure t is a typelist and any one of the types in the typelist is unique whenever the vocab's nested type t is used, but i will spare you in the name of terseness.

the message id as integer:

now we have the vocabulary with its type ids. what is the most apt way of sending this type from me to you? an semi-educated guess would be an unsigned integer as small as can be, given the number of types in our conversation. given s types indexed from 0 to (s-1), this is hopefully a way of finding the smallest uint to represent them (in the namespace AUX):

struct least{};

template<class... ts> struct uint_h{ static_assert(sizeof...(ts)<0,"AUX uint_h error"); };

template<int s>
struct uint_h<least,idx<s>>{
typedef conditional_t<
s<=256, //2^8
uint_least8_t,
conditional_t<
s<=65536, //2^16
uint_least16_t,
conditional_t<
s<=4295976296,
uint_least32_t,
uint_least64_t
>
>
> t;
};

template<class property,int bits>
using uint_t=T<uint_h<property,idx<bits>>>;

template<int bits>
using uint_least_t=uint_t<least,bits>;

the 'least' awkwardness due to future expansion. thus we can define an apt message ingteger type given a conversation id and its vocabulary in the namespace GUT:

template<class convo_id>
using msg_t=uint_least_t<N<T<vocab<convo_id>>>()>;


the mux

so far we have and id representing a conversation, the corresponding vocabulary of the conversation as well as what we hope is an apt integer type for carrying the message id from me to yue. here comes the convertion from message id to message integer in the namespace GUT:

template<class convo_id>
struct mux{
template<class msg_id>
static constexpr msg_t<convo_id>
a(){ return I<msg_id,T<vocab<convo_id>>>(); }
};

as well as a convenience function in the global namespace (it might as well just be a function):

template<class convo_id,class msg_id>
constexpr GUT::msg_t<convo_id>
mux(){
return GUT::mux<convo_id>::template a<msg_id>();
}


the intermezzo

ah halfway there, but the dragon's roar is yet but a whisper. we have a way of defining a conversation, with corresponding vocabulary, and a way for translating a message into a fitting integer. we have a to, but what's the fro? what's an apt mechanism for receiving an int and forwarding it as a msg id again? enter function spaces.

the function space

take a template function and a list of types, for each type in the typelist, instantiate the function with the given type, and store the function pointer in an array. now residing at the ith index of the array is a function pointer to the former template function instantiated with the ith type in the typelist. voila, you got your function space (it works for type-coordinates too).

the function trait

ok, so we identify with each convo a function that we will use to generate a function space:

template<class convo_id,class=void>
struct fn{ static_assert(sizeof(convo_id)==0,"fn not defined"); };

the implicit assumption is that this trait will define the type of the instantiated function as a nested typedef t as well as a static template member function a that takes a msg_id as input and provides a function pointer of the type t as output.

we also provide the convenience alias template to extract the function type:
template<class convo_id>
using fn_t=T<fn<convo_id>>;


sweet. now lets get to the juiciest and hariest bit.

the demux

to tie it all together we now will define the fro.

it consists of an array of funtion pointers, whose type is defined in the function trait, instantiated with the message ids defined in the vocab trait. the type of the array is denoted F_t, and the array itself F.

this array will be generated by a nested helper class called gen defined as templated on a parameter pack to enable in class specialization without a dummy parameter. the demux class will aslo provide a static member function that takes a fitting integer msg as input and outputs the corresponding function pointer.

template<class convo_id>
struct demux{
typedef std::array<
fn_t<convo_id>,
N<T<vocab<convo_id>>>()
> F_t;

static const F_t F;

template<class... ts>
struct gen{ static_assert(sizeof...(ts)<0,"GUT gen error"); };

template<class... msgs>
struct gen<tl<msgs...>>{
static F_t a(){ return {fn<convo_id>::template a<msgs>()... }; }
};

static
fn_t<convo_id> const&
a(msg_t<convo_id> msg){
return F[msg];
}
};


initalizing the array for every convo calling gen's a instantiated with its messages.

template<class convo_id>
typename demux<convo_id>::F_t const
demux<convo_id>::F(
demux<convo_id>::gen<T<vocab<convo_id>>>::a()
);


all of it in the namespace GUT. cherry on top a convenience function demux in global namespace:

template<class convo_id>
GUT::fn_t<convo_id>
demux(GUT::msg_t<convo_id> msg){
return GUT::demux<convo_id>::a(msg);
}


the end

and so we have a way of defining a type conversation, it's type vocabulary, a translation from a type to a fitting integer and back again to a function instantiated with the given type that can be called at your pleasure.

on the talking end the message id is resolved into an integer at compile time, while at the receiving end it amounts to a lookup to retreive the message id from the integer.

the example

a trivial example where we just talk with ourself in process memory.

we define the conversation id
struct nunez{};

the message ids
struct team{}; struct liquid{}; struct dot{}; struct net{};

the function template
template<class msg_id> void f(){}
template<>
void f<team>(){
std::cout<<"this is team";
}
template<>
void f<liquid>(){
std::cout<<"liquid";
}
template<>
void f<dot>(){
std::cout<<'.';
}
template<>
void f<net>(){
std::cout<<"net\n";
}

the specialization of the convo to the framework in the namespace GUT
template<> struct vocab<nunez>{ typedef tl<team,liquid,dot,net> t; };

template<>
struct fn<nunez>{
typedef void(*t)();
template<class msg>
static t a(){
return &f<msg>;
}
};


a global message queue and functions to send and receive messages from to the convo
typedef std::queue<
GUT::msg_t<nunez>
> msg_q_t;

msg_q_t m;

void snd(GUT::msg_t<nunez> msg){
m.push(msg);
}

GUT::msg_t<nunez> rcv(){
auto msg=m.front();
m.pop();
return msg;
}


and the program sending team,liquid,dot,net after muxing them to ints receiving them and calling the function correspoding to the demuxed message:
int main(){
snd(mux<nunez,team>());
snd(mux<nunez,liquid>());
snd(mux<nunez,dot>());
snd(mux<nunez,net>());
while(m.size()) demux<nunez>(rcv())();
}


the output

[jeh@gimli aux]$ make
g++ -c -std=c++0x -I. -Wfatal-errors -I.. main.cpp
g++ -o main main.o
rm -rf *.o
[jeh@gimli aux]$ ./main
this is teamliquid.net


src

feedback / comments welcome. it was made to solve the problem of sending simple semantic messages from one process to another through sockets and kernel message queues, all of the different messages and their specific callsites known at compile time.
conspired against by a confederacy of dunces.
Manit0u
Profile Blog Joined August 2004
Poland17798 Posts
Last Edited: 2014-03-29 21:45:27
March 29 2014 21:42 GMT
#9184
Newline shouldn't be a part of "net" template - big part of magic behind semantic ideas and templates is the fact that you can mix and match them in various ways to achieve different meaning, conveying the end of something should be a template in itself. Dot shouldn't be a string but a char.
Time is precious. Waste it wisely.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 29 2014 22:02 GMT
#9185
I'm surprised I still understand most of this despite not actually having written any C++ in years.

Sometimes I really miss templates in C#... So powerful!
If you have a good reason to disagree with the above, please tell me. Thank you.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2014-03-30 08:51:50
March 30 2014 08:35 GMT
#9186
On March 30 2014 06:42 Manit0u wrote:
Newline shouldn't be a part of "net" template - big part of magic behind semantic ideas and templates is the fact that you can mix and match them in various ways to achieve different meaning, conveying the end of something should be a template in itself. Dot shouldn't be a string but a char.


ah thx, i'm wasn't quite sure how string/char literals work, excellent catch. a byte here, a byte there!

code
std::cout<<"literal: "<<'.'<<" size: "<<sizeof('.')<<" type: "<<to_string<decltype('.')>()<<std::endl;
std::cout<<"literal: "<<"."<<" size: "<<sizeof(".")<<" type: "<<to_string<decltype(".")>()<<std::endl;

output
literal: . size: 1 type: [char]
literal: . size: 2 type: [char [2]]

the example is poorly chosen, and the behaviour of the 'receiving function' as well as the messages are arbitrary, there just to showcase the concept of the type -> integer -> type framework. where type->integer mux is a metafunction (compile time) and integer->type demux is a constant time lookup runtime in template function-space.

On March 30 2014 07:02 spinesheath wrote:
I'm surprised I still understand most of this despite not actually having written any C++ in years.

Sometimes I really miss templates in C#... So powerful!


yes, and so much you don't know you don't know. wow, much explore, many possibilities, such T.
this code is terse and quirky. so maybe a bad indicator even.
conspired against by a confederacy of dunces.
CatNzHat
Profile Blog Joined February 2011
United States1599 Posts
March 30 2014 09:20 GMT
#9187
On March 29 2014 06:10 gOst wrote:
Hello everyone. This is my first time posting is this thread so please be gentle. I will soon start my third year on a bachelor of software development, major in CS and I was thinking of getting into developing APIs. I'm half decent with C++ and Java and have dabbled somewhat in Python as well.
Is there any career what so ever in developing APIs?
Is there some particular skill/knowledge that could be useful?

Good API design is a very difficult challenge, read some books on the subject and see if it's for you. There are a few companies that I've interviewed with over the past couple months that are almost exclusively API driven development shops. TwitchTV is one of them.

API driven development can lead to very clean decoupled modular applications working together to solve a larger problem, and Twitch's business needs are just that. The chat engine is a separate application, as is the web interface for browsing and viewing streams. They interact with each other through their APIs, allowing them to be updated asynchronously leading to easier maintenance/development. If business needs are not being solved by this engineering approach then no reason to try to solve your problem with tools that make your job harder in the end or hurt the business.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2014-03-30 11:29:08
March 30 2014 11:27 GMT
#9188
I was wondering if it's ok to type:


if (instance == null) { return; }


instead of:


if (instance == null) {
return;
}


What is usually the norm?

Edit: the above C++ code looks complex and a bit unreadable. Maybe it's C++'s fault. I just think Java is a lot easier.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2014-03-30 12:05:34
March 30 2014 12:04 GMT
#9189
On March 30 2014 20:27 darkness wrote:
I was wondering if it's ok to type:


if (instance == null) { return; }


instead of:


if (instance == null) {
return;
}


What is usually the norm?

Edit: the above C++ code looks complex and a bit unreadable. Maybe it's C++'s fault. I just think Java is a lot easier.

If you do that, you usually would just write

if (instance == null) return;

Of course there also is:

if (instance == null)
return;

I personally prefer:

if (instance == null)
{
return;
}

Also if this is C/C++, you should prefer:

if (null == instance)

In any case, there's no real norm to that. Just do it consistently.

Templates have this habit of being hard to read. To compensate, they're extremely powerful.
If you have a good reason to disagree with the above, please tell me. Thank you.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2014-03-30 12:11:44
March 30 2014 12:11 GMT
#9190
and use nullptr if that's a pointer and it's c++!
yes, the code is (probably) relatively complex, and my careless coding isn't doing you any favors.
i would go for spinesheaths first option personally, so terse.
conspired against by a confederacy of dunces.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 30 2014 12:17 GMT
#9191
Oh right, nullptr. Just shows that I've not been writing any C++ code.
If you have a good reason to disagree with the above, please tell me. Thank you.
CatNzHat
Profile Blog Joined February 2011
United States1599 Posts
March 30 2014 17:09 GMT
#9192
On March 30 2014 20:27 darkness wrote:
I was wondering if it's ok to type:


if (instance == null) { return; }


instead of:


if (instance == null) {
return;
}


What is usually the norm?

Edit: the above C++ code looks complex and a bit unreadable. Maybe it's C++'s fault. I just think Java is a lot easier.

Typical style guidelines would say

if (null == instance) {
return
}

The reason for null == <var> here is that instance is already the context when reading, so you read it as 'if null return' which is easier for people to read.
The reason you leave the block there even though it's a one-liner is that if you were to add another operation before the return you'd end up with a cleaner diff which makes code reviews easier. This one is debatable, and if you have a pattern of one-liner conditionals you'd probably make an exception case for those use cases.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 30 2014 17:22 GMT
#9193
I find
if(null == instance)

a lot harder to read.
The reason for writing it like this is C/C++'s implicit pointer to bool conversion which screws you over if you accidentally write only a single '='.
If you have a good reason to disagree with the above, please tell me. Thank you.
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2014-03-30 17:34:43
March 30 2014 17:30 GMT
#9194
On March 30 2014 21:04 spinesheath wrote:
If you do that, you usually would just write

if (instance == null) return;

Of course there also is:

if (instance == null)
return;

NOOOOOOOOOO never do this. Never never never. Always do what you prefer here:

On March 30 2014 21:04 spinesheath wrote:
I personally prefer:

if (instance == null)
{
return;
}



This is the reason:

Your code in Year X:

if (fooConditional)
doThing();


... Your code sits around for 2-3 years

Your code in Year X + 3 after someone modifies it along with a whole bunch of other code:

if (fooConditional)
doFirstThing();
doThing();


Extreme badness ensues. For the most recent catastrophic example, see Apple's bug which compromised SSL/TLS in OSX and iOS:
http://opensource.apple.com/source/Security/Security-55471/libsecurity_ssl/lib/sslKeyExchange.c

(oop, go to line 631 there, bit far down)

Ideally you have stuff set up to catch this, such that missing { } after if () is not allowed.
Who after all is today speaking about the destruction of the Armenians?
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2014-03-30 17:31:42
March 30 2014 17:30 GMT
#9195
if you one line statements you are a horrible person and should be burned at the stake :<

also if you don't use braces when it's optional to use them you should be burned at your local bbq :>
There is no one like you in the universe.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 30 2014 17:50 GMT
#9196
It's coding standard where I work. I argued against it, but who listens to the newbie?

That Apple bug is hilarious.
If you have a good reason to disagree with the above, please tell me. Thank you.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2014-03-30 18:14:44
March 30 2014 18:13 GMT
#9197
so you write it like this:
if(the_bloob) do_the_bleeb();


so terse, impossible to misunderstand! and adding on another call writes itself:
if(the_bloob) do_the_bleeb(),and_the_bluub();
conspired against by a confederacy of dunces.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 30 2014 18:21 GMT
#9198
You did overload
operator,()
there, didn't you?
If you have a good reason to disagree with the above, please tell me. Thank you.
Amnesty
Profile Joined April 2003
United States2054 Posts
March 30 2014 18:28 GMT
#9199
I have to implement a graph shortest path algorithm for homework.
I finished it and works fine but I ran into a problem i'm still perplexed by any explaination would be nice
VS2010

I have this function used internally during the algorithm that gets a node based on the id.
If it currently does not exist it creates one with default values (not visited, infinite distance, etc)
then returns the iterator to that.

std::vector<GraphNode>::iterator graph::get_node(std::string id, std::vector<GraphNode>& nodes)
{
for(auto i = nodes.begin(); i != nodes.end(); ++i)
{
if(i->node_id == id)
{
return i;
}
}
GraphNode gn(id);
nodes.push_back(gn);
return get_node(id, nodes);
}

So thats the working version, notice the recursion.


However this does not work

std::vector<GraphNode>::iterator graph::get_node(std::string id, std::vector<GraphNode>& nodes)
{
for(auto i = nodes.begin(); i != nodes.end(); ++i)
{
if(i->node_id == id)
{
return i;
}
}
GraphNode gn(id);
nodes.push_back(gn);
return nodes.rbegin().base();
}


Using the returned iterator throws asserts?!
It should always be valid. i just push_backed a element so rbegin() should always be valid
calling base on that just turns a reverse_iterator into a regular one.

So i'm pretty lost of why this fails.
The sky just is, and goes on and on; and we play all our BW games beneath it.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2014-03-30 19:01:20
March 30 2014 18:32 GMT
#9200
On March 31 2014 03:21 spinesheath wrote:
You did overload
operator,()
there, didn't you?

of course! that's always the first thing i do when i define a class.

@amnesty(woops) your code works on my puter. uh well when it finds one it does.

std::reverse_iterator::base

Returns the underlying base iterator.

The base iterator refers to the element that is next to the element the reverse_iterator is currently pointing to. That is std::reverse_iterator(it).base() == std::next(it).
src

ok so since you push_back() and do rbegin(), that is the last element. the base() of that will give you the next element of the last element, that is std::end(nodes):
std::vector::end, std::vector::cend

Returns an iterator to the element following the last element of the container.

This element acts as a placeholder; attempting to access it results in undefined behavior.
src
you can use (--it), since this is the last element. either do
return --nodes.rbegin().base(); 

or be careful when you use it, or simplest just
return nodes.back();

conspired against by a confederacy of dunces.
Prev 1 458 459 460 461 462 1032 Next
Please log in or register to reply.
Live Events Refresh
Kung Fu Cup
11:00
2026 Week 16
IntoTheiNu 1448
WardiTV655
RotterdaM540
Ryung 387
TKL 192
Rex128
SteadfastSC126
EnkiAlexander 24
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 540
Ryung 387
TKL 192
Rex 128
SteadfastSC 126
BRAT_OK 17
trigger 3
StarCraft: Brood War
Calm 4412
Rain 2911
Jaedong 1476
Horang2 1097
firebathero 731
BeSt 546
EffOrt 483
Light 368
Soulkey 336
Rush 246
[ Show more ]
Snow 242
Stork 239
Soma 230
ZerO 227
hero 213
ggaemo 203
Zeus 148
Last 142
Dewaltoss 135
Hyun 113
Leta 112
Mong 87
Killer 80
Pusan 78
sorry 60
[sc1f]eonzerg 48
NaDa 46
ToSsGirL 40
Movie 29
JulyZerg 27
JYJ 26
Nal_rA 25
Aegong 21
GoRush 21
Hm[arnc] 19
Sexy 19
yabsab 18
Sacsri 17
Yoon 13
IntoTheRainbow 12
ajuk12(nOOB) 12
Noble 10
Terrorterran 8
zelot 8
Rock 6
Dota 2
qojqva906
XcaliburYe272
syndereN13
League of Legends
KnowMe30
Counter-Strike
fl0m2752
Other Games
FrodaN3730
B2W.Neo717
hiko587
Lowko532
Mlord361
uThermal281
Liquid`LucifroN188
Pyrionflax159
ArmadaUGS110
ToD45
Trikslyr34
CosmosSc2 27
ZerO(Twitch)14
Organizations
StarCraft: Brood War
lovetv 14
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 15 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 2365
• WagamamaTV316
League of Legends
• Nemesis1131
• Stunt600
• TFBlade525
Upcoming Events
OSC
10h 37m
CrankTV Team League
21h 37m
Replay Cast
1d 10h
CrankTV Team League
1d 21h
Korean StarCraft League
2 days
Afreeca Starleague
2 days
RSL Revival
2 days
Serral vs SHIN
herO vs Solar
Online Event
3 days
Replay Cast
3 days
RSL Revival
3 days
Clem vs ByuN
Rogue vs Lambo
[ Show More ]
OSC
3 days
WardiTV Weekly
4 days
Sparkling Tuna Cup
5 days
PiGosaur Cup
6 days
The PondCast
6 days
Kung Fu Cup
6 days
Liquipedia Results

Completed

Proleague 2026-07-21
HSC XXIX
Eternal Conflict S2 E3

Ongoing

CSL 2026 Summer (S21)
KCM Race Survival 2026 Season 3
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026

Upcoming

Escore Tournament S3: W4
ASL S22 SEASON OPEN Day 2
Escore Tournament S3: W5
ASL Season 22: Qualifier #1
ASL Season 22: Qualifier #2
CSLAN 4
ASL Season 22
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
ESL Pro League Season 24
Stake Ranked Episode 4
Logitech G Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.