Thread overview |
---|
January 06, 2006 Compiler complains of copy on implied return for an STL vector | ||||
---|---|---|---|---|
| ||||
Guys; I'm attempting to work through a series of STL examples from a back issue of the C++ report and my step 1 program looks like the following: #include <vector> vector<int> less_than_10(const vector<int>& vec) { vector<int> nvec; for (int i = 0; i < vec.size(); ++i) { if (vec[i] < 10 ) { nvec.push_back( vec[i] ); } } return nvec; } Anyway I compile and get this error: sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf -IC:\dm\include -I c:\dm\stl -otrythis.obj Error: C:\DM\PROGRAMS\trythis.c(23): implied return of vector<int ,__default_alloc_template<0,0> >::_M_allocate_and_copy at closing '}' does not return value Lines Processed: 5046 Errors: 1 Warnings: 0 Build failed I have to mention that this is my 1st programming attempt with Digital Mars and yes it is an older version 7.5.3. I am including the STL library in my project and the compiler is finding vector. If anyone has an idea of what's going on I'd appreciate some help. Rick hessrt@earthlink.net |
January 07, 2006 Re: Compiler complains of copy on implied return for an STL vector | ||||
---|---|---|---|---|
| ||||
Posted in reply to hessrt | hessrt@earthlink.net wrote: > Guys; > > I'm attempting to work through a series of STL examples from a back issue of the > C++ report and my step 1 program looks like the following: > > #include <vector> > > > vector<int> less_than_10(const vector<int>& vec) > { > vector<int> nvec; > > for (int i = 0; i < vec.size(); ++i) > { > if (vec[i] < 10 ) > { > nvec.push_back( vec[i] ); > } > } > > return nvec; > } > > Anyway I compile and get this error: > sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf > -IC:\dm\include -I c:\dm\stl -otrythis.obj Error: C:\DM\PROGRAMS\trythis.c(23): implied return of vector<int > ,__default_alloc_template<0,0> >::_M_allocate_and_copy at closing '}' does not > return value > Lines Processed: 5046 Errors: 1 Warnings: 0 > Build failed > > > > I have to mention that this is my 1st programming attempt with Digital Mars and > yes it is an older version 7.5.3. I am including the STL library in my project > and the compiler is finding vector. If anyone has an idea of what's going on I'd > appreciate some help. Upgrade your compiler to a more recent version with better ansi/iso c++ template and stl support. It is really easy to do. > > Rick > hessrt@earthlink.net |
January 07, 2006 Re: Compiler complains of copy on implied return for an STL vector | ||||
---|---|---|---|---|
| ||||
Posted in reply to hessrt | Your environment and/or SC.INI is including the old HP headers, and not STLport, which is all that DMC++ is supported with. <hessrt@earthlink.net> wrote in message news:dpmg3l$1jsv$1@digitaldaemon.com... > Guys; > > I'm attempting to work through a series of STL examples from a back issue > of the > C++ report and my step 1 program looks like the following: > > #include <vector> > > > vector<int> less_than_10(const vector<int>& vec) > { > vector<int> nvec; > > for (int i = 0; i < vec.size(); ++i) > { > if (vec[i] < 10 ) > { > nvec.push_back( vec[i] ); > } > } > > return nvec; > } > > Anyway I compile and get this error: > sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf > -IC:\dm\include -I c:\dm\stl -otrythis.obj > Error: C:\DM\PROGRAMS\trythis.c(23): implied return of vector<int > ,__default_alloc_template<0,0> >::_M_allocate_and_copy at closing '}' does > not > return value > Lines Processed: 5046 Errors: 1 Warnings: 0 > Build failed > > > > I have to mention that this is my 1st programming attempt with Digital > Mars and > yes it is an older version 7.5.3. I am including the STL library in my > project > and the compiler is finding vector. If anyone has an idea of what's going > on I'd > appreciate some help. > > Rick > hessrt@earthlink.net |
January 08, 2006 Re: Compiler complains of copy on implied return for an STL vector | ||||
---|---|---|---|---|
| ||||
Posted in reply to hessrt | <hessrt@earthlink.net> wrote in message news:dpmg3l$1jsv$1@digitaldaemon.com... > Anyway I compile and get this error: > sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf > -IC:\dm\include -I c:\dm\stl -otrythis.obj Use -I\dm\stlport\stlport instead of \dm\stl |
January 09, 2006 Re: Compiler complains of copy on implied return for an STL vector | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Thnks guys for the assist. I used the "-I\dm\stlport\stlport" and it worked great. In article <dprqel$1h80$1@digitaldaemon.com>, Walter Bright says... > > ><hessrt@earthlink.net> wrote in message news:dpmg3l$1jsv$1@digitaldaemon.com... >> Anyway I compile and get this error: >> sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf >> -IC:\dm\include -I c:\dm\stl -otrythis.obj > >Use -I\dm\stlport\stlport instead of \dm\stl > > |
January 09, 2006 Re: Compiler complains of copy on implied return for an STL vector | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Thanks Guys: The include of \dm\stlport\stlport worked great. In article <dprqel$1h80$1@digitaldaemon.com>, Walter Bright says... > > ><hessrt@earthlink.net> wrote in message news:dpmg3l$1jsv$1@digitaldaemon.com... >> Anyway I compile and get this error: >> sc trythis.c -A -cpp -Ae -Ar -r -J -mnw -C -WA -S -5 -a4 -c -l -gf >> -IC:\dm\include -I c:\dm\stl -otrythis.obj > >Use -I\dm\stlport\stlport instead of \dm\stl > > Rick Hess |
Copyright © 1999-2021 by the D Language Foundation