Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

101 Neutral

About Luke1410

  • Rank

Personal Information

  • Interests


  • Github
  1. Just wanted to quickly reach out and send you a note that we have integrated source code in our new network library (SLikeNet - see https://www.slikesoft.com/?page_id=1224&lang=en for details) which is marked with a copyright note asking for such a notification [1] and a post in this forum was the only means of communication I could find. The library is in principle a fork of the (discontinued) RakNet library and also available on GitHub (https://github.com/SLikeSoft/SLikeNet). We made some modifications to the source code to: - resolve a compiler warning (with VS) - provide Unicode support Feel free to reuse the changes under the same license you consider your own copyright source code to be licensed under. Alternatively we always provide our modifications under the MIT license. That said, thanks for providing the that code. The work you put into is much appreciated. [1] https://www.slikesoft.com/svn/slikenet/tags/0.1.0/DependentExtensions/DXTCompressor/Src/OpenGLWindow.hpp
  2. Luke1410

    templates and using directive

    Just to complete this thread: PC Lint's latest beta (version 9.0d3) no longer raises the reported error. Hence I suspect that it indeed was a bug in the parser/compiler and the syntax complies to the C++ standard. Again, thanks for ur replies to this thread.
  3. Luke1410

    templates and using directive

    You are of course right in that my reference is a little outdated. :-) However, I wouldn't use the C++0x draft u referenced simply because our projects still rely on C++98/C++03 (aka VS 2005/2008 w/o TR1). But in order to update my statements a bit, I'll refer to the C++03 standard: Section 9.2 changed a bit, but the argument still stands: paragraph 4: "A member-declarator can contain a constant-initializer only if it declares a static member (9.4) of integral or enumeration type, see 9.4.2." However, concerning the recited section 6.8: That paragraph has been removed and I couldn't easily spot any corresponding reference in the C++03 standard. So feel free to ignore that. :-) Since the both of you didn't really spot an obvious error in my code sample, I think I'll go forward and send out a support request to gimpel to see what they make of it. Thanks for the discussion.
  4. Luke1410

    templates and using directive

    Please correct me if I'm wrong about anything here --- I just read through the standard and hence think there are some contradictary statements to urs. I'm refering to "The annotated C++ reference manual" from 1990: Quote: This is semantic ambiguity, the compiler cannot tell whether find is declaration of function, or whether it's declaring a variable using no-arg constructor. [9.2 p171]: "Note that a member-declarator cannot contain an initializer." If I take that into account I'd argue that even if there is an ambiguity here for non-context sensitive lexers, it should be properly parsed by the parser, simply because of the parantheses after the identifier "find" which by the standard cannot be a variable using the "no-arg constructor" (or the "Explicit type conversion" as it is called in the standard --- unless I mixed those here). Quote: Can be function i returning an int, can be variable i no-arg constructed - compiler can't tell. [6.8 p94]: "A slight different ambiguity between expression-statements and declarations is resolved by requiring a type-name for function declarations within a block." Therefore must not "int i()" be considered a function declaration in ur given example and hence the compiler must be possible to resolve the ambiguity again? Quote: The ambiguity likely exists since at that point, templates haven't been instantiated yet, so function definition of find<T> doesn't exist. That would make sense, if PCLint wouldn't omit the error message, if I use either of these definitions for class Foo: // example 1 template<class T> class Foo : public T { void find(); // works fine now using T::find; }; // example 2 template<class T> class Foo : public T { typename T::iterator find(); // works fine now }; Or did I miss ur point somewhere? Just as a sidenote: Quote: PCLint is generally right, but getting rid of all the errors it reports is often not viable. I agree that especially the past versions of PCLint (version 8.x) were really a PITA to get to work with larger production code (especially when used for non-embedded projects). However version 9.0 introduced proper support for PCHs and also made some significant improvements with MS VS compiler environments so that with our current code I'm down to just a few "errors". I'm just talking about errors here, because they leave PCLint with not recognizing the correct code structure and lead to undeserved warnings later in the code just because PC Lint doesn't have the knowledge of Foo being an enum or somesuch. So if u gave it a try in the past, u might wanna take another look at the current version, which really made it a lot more useable.
  5. Hi, I'm having some difficulties getting the following sample parsed by some compiler/parser and am wondering whether the syntax is correct according to the C++ standard. The following code snippet represents the issue: template<class T> class Foo : public T { typename T::iterator find(); using T::find; }; template<class T> typename T::iterator Foo<T>::find() { return T::find(); } class Bar { public: typedef int iterator; iterator find() { return 5; } }; void main() { } The error message I'm getting from the parser (in this case PC Lint) is: Quote: Issue 1051: (Error -- Symbol 'find' is both a function and a variable) The interesting thing is that when I either remove "using T::find;" or replace "typename T::iterator find();" with "int find();" the parser accepts the construct. Now I'm wondering whether I've used some non-100% conformant C++ syntax or whether there's really a flaw in the 3rd party tool.
  6. absolutely right as usual, SiCrane :-) Thanks alot.
  7. I've got a riddle which kept me occupied for several days... The following code compiles fine with VS 05/08: #include <set> class A {}; template<class _Ty> struct _Allocator_base { typedef _Ty value_type; }; template<class T> class FooBar { void address(typename std::_Allocator_base<T>::value_type&) const { } void address(const typename std::_Allocator_base<T>::value_type&) const { } }; int main() { FooBar<const A* const> alloc2; return 0; } However, if I change it slightly to the following (by removing the std:: in the address-method signatures), the code no longer compiles and I get the following error message: main.cpp(17) : error C2535: 'void FooBar<T>::address(const A *const &) const' : member function already defined or declared The code which won't work: #include <set> class A {}; template<class _Ty> struct _Allocator_base { typedef _Ty value_type; }; template<class T> class FooBar { void address(typename _Allocator_base<T>::value_type&) const { } void address(const typename _Allocator_base<T>::value_type&) const { } }; int main() { FooBar<const A* const> alloc2; return 0; } I understand that two methods like these are considered the same and therefore cause the aforementioned error message: void foo(const A* const&); void foo(const const A* const&); The question remains: Why does the first code example work regardless of this fact?
  8. Thanks for all the answers... I poked a bit deeper into the STL and it is as we suspected initially: Since the standard does not directly require that containers using different allocators are interchangeable, it's not supported by the implementation. There would be one obvious possibility I can think of to add that support: Add a cpy ctor to any container class, which accepts any kind of allocator and compare the two allocators using the ==-operator to see if the allocators are interchangable. However, this would have to be done by Dinkumware to be consistent, so we'll stick with the assign-cpy-suggestion provided here.
  9. Quote:Original post by magic_man Instead of using the assignment operator you may want to define your own function maybe something like the following. *** Source Snippet Removed *** That looks merely like a variation of the suggestions already given above by chairthrower and SiCrane, or did I miss something? Thanks for the reply, anyway.
  10. Quote:Original post by stonemetal have you tried boxing the int? somthing like struct PoolID{ PoolID(int a): Pool(a){} int Pool; }; vector<int, myalloc<int, PoolID(5)> > foo; That way you have a unified type for your template. I'm a bit lost with this suggestion. How should the myalloc template class look like? I mean if I declare it as: template<typename T, typename T2> class myalloc {} it won't compile, because it would expect a typename not an instance of an actual class for T2. If I tried template<typename T, PoolID T2> class myalloc {} that won't work either, because PoolID is not a constant type and therefore can't be resolved as a template parameter, or am I missing the point here?
  11. @SiCrane: Thanks for the reply, that would definitely work. However I'm still struggling with trying to get the allocator to work automatically... Trying to compile the following minimalistic example, I get these compile errors: Quote: 1>g:\c++\c++-test\vs_test_projects\deduction_test\main.cpp(71) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::vector<_Ty,_Ax>' (or there is no acceptable conversion) 1> with 1> [ 1> _Ty=int, 1> _Ax=TrackedAllocator<int,Pool2> 1> ] 1> e:\program files (x86)\microsoft visual studio 9.0\vc\include\vector(562): could be 'std::vector<_Ty,_Ax> &std::vector<_Ty,_Ax>::operator =(const std::vector<_Ty,_Ax> &)' 1> with 1> [ 1> _Ty=int, 1> _Ax=TrackedAllocator<int,Pool1> 1> ] 1> while trying to match the argument list '(std::vector<_Ty,_Ax>, std::vector<_Ty,_Ax>)' 1> with 1> [ 1> _Ty=int, 1> _Ax=TrackedAllocator<int,Pool1> 1> ] 1> and 1> [ 1> _Ty=int, 1> _Ax=TrackedAllocator<int,Pool2> 1> ] #include <iostream> #include <conio.h> #include <vector> enum MemType { Pool1, Pool2 }; template<typename T, MemType memtype> class TrackedAllocator { public: typedef T value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; template<typename Other> struct rebind { typedef TrackedAllocator<Other, memtype> other; }; public: TrackedAllocator() throw() { } template<typename OtherAlloc> TrackedAllocator(const OtherAlloc&) throw() { } ~TrackedAllocator() throw() { } pointer address(reference ref) const { return &ref; } const_pointer address(const_reference ref) const { return &ref; } size_type max_size() const { return std::numeric_limits<size_type>::max(); } pointer allocate(size_type numelements) const { return static_cast<pointer>( malloc(numelements * sizeof(T))); } void deallocate(pointer ptr, size_type numelements) const { free(ptr); } void construct(pointer ptr, const_reference value) const { ::new(static_cast<void*>(ptr)) T(value); } void destroy(pointer ptr) const { (ptr)->~T(); } private: TrackedAllocator& operator=(const TrackedAllocator&); }; template<typename T1, MemType MT1, typename T2, MemType MT2> inline bool operator ==(const TrackedAllocator<T1, MT1>&, const TrackedAllocator<T2, MT2>&) { return true; } template<typename T, MemType MT, typename OtherAllocator> bool operator ==(const TrackedAllocator<T, MT>&, OtherAllocator const&) { return false; } int main() { std::vector<int, TrackedAllocator<int, Pool1> > vec1; std::vector<int, TrackedAllocator<int, Pool2> > vec2; vec1 = vec2; return 0; } Has anybody any further ideas or can explain why it doesn't work at all? [Edited by - Luke1410 on March 19, 2009 4:39:41 PM]
  12. Luke1410

    [Lua] Tables within tables

    not "pkBeamWeap[1].['exists']" but rather pkBeamWeap[1]['exists'] (i.e. without the ".") This article might be of interest to you: http://www.lua.org/pil/3.6.html I would run a quick test here, but I currently don't have any test environment for lua set up and don't have the time right now to do so. If that article doesn't help you I'll try to test it later tonight at home to check out where exactly the problem with the syntax is.
  13. Luke1410

    [Lua] Tables within tables

    well, i'm not 100% sure about that, but if I remember correctly and don't mix that up with another script language local bullet = { subtable = { val = 6 } } creates the following table: bullet['subtable'] = { ['val'] = 6 } therefore accessing it in ur example is done that way: weapon[#weapon]['subtable']['val']
  14. Luke1410

    Code Composer

    Since I don't have CCS I'm unable to test that case, but did u try the following? typedef typename std::pair<T, unsigned int> TimedEvent;
  15. Luke1410

    [Lua] Tables within tables

    I'd go with RTFM, since the whole construct looks wrong there... If I assume correctly, what you plan to do, here's an example which should work (untested): local mytable; mytable = {} table.insert(mytable, weapon, bullet) mytable[weapon].subtable = 5
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!